2 * jQuery JavaScript Library v1.4.1
5 * Copyright 2010, John Resig
9 * Copyright 2010, The Dojo Foundation
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Date: Mon Jan 25 19:43:33 2010 -0500
31 (function( window
, undefined ) {
33 // Define a local copy of jQuery
34 var jQuery = function( selector
, context
) {
35 // The jQuery object is actually just the init constructor 'enhanced'
36 return new jQuery
.fn
.init( selector
, context
);
39 // Map over jQuery in case of overwrite
40 _jQuery
= window
.jQuery
,
42 // Map over the $ in case of overwrite
45 // Use the correct document accordingly with window argument (sandbox)
46 document
= window
.document
,
48 // A central reference to the root jQuery(document)
51 // A simple way to check for HTML strings or ID strings
52 // (both of which we optimize for)
53 quickExpr
= /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
55 // Is it a simple selector
56 isSimple
= /^.[^:#\[\.,]*$/,
58 // Check if a string has a non-whitespace character in it
61 // Used for trimming whitespace
62 rtrim
= /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
64 // Match a standalone tag
65 rsingleTag
= /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
67 // Keep a UserAgent string for use with jQuery.browser
68 userAgent
= navigator
.userAgent
,
70 // For matching the engine and version of the browser
73 // Has the ready events already been bound?
76 // The functions to execute on DOM ready
79 // The ready event handler
82 // Save a reference to some core methods
83 toString
= Object
.prototype.toString
,
84 hasOwnProperty
= Object
.prototype.hasOwnProperty
,
85 push
= Array
.prototype.push
,
86 slice
= Array
.prototype.slice
,
87 indexOf
= Array
.prototype.indexOf
;
89 jQuery
.fn
= jQuery
.prototype = {
90 init: function( selector
, context
) {
91 var match
, elem
, ret
, doc
;
93 // Handle $(""), $(null), or $(undefined)
98 // Handle $(DOMElement)
99 if ( selector
.nodeType
) {
100 this.context
= this[0] = selector
;
105 // Handle HTML strings
106 if ( typeof selector
=== "string" ) {
107 // Are we dealing with HTML string or an ID?
108 match
= quickExpr
.exec( selector
);
110 // Verify a match, and that no context was specified for #id
111 if ( match
&& (match
[1] || !context
) ) {
113 // HANDLE: $(html) -> $(array)
115 doc
= (context
? context
.ownerDocument
|| context
: document
);
117 // If a single string is passed in and it's a single tag
118 // just do a createElement and skip the rest
119 ret
= rsingleTag
.exec( selector
);
122 if ( jQuery
.isPlainObject( context
) ) {
123 selector
= [ document
.createElement( ret
[1] ) ];
124 jQuery
.fn
.attr
.call( selector
, context
, true );
127 selector
= [ doc
.createElement( ret
[1] ) ];
131 ret
= buildFragment( [ match
[1] ], [ doc
] );
132 selector
= (ret
.cacheable
? ret
.fragment
.cloneNode(true) : ret
.fragment
).childNodes
;
137 elem
= document
.getElementById( match
[2] );
140 // Handle the case where IE and Opera return items
141 // by name instead of ID
142 if ( elem
.id
!== match
[2] ) {
143 return rootjQuery
.find( selector
);
146 // Otherwise, we inject the element directly into the jQuery object
151 this.context
= document
;
152 this.selector
= selector
;
157 } else if ( !context
&& /^\w+$/.test( selector
) ) {
158 this.selector
= selector
;
159 this.context
= document
;
160 selector
= document
.getElementsByTagName( selector
);
162 // HANDLE: $(expr, $(...))
163 } else if ( !context
|| context
.jquery
) {
164 return (context
|| rootjQuery
).find( selector
);
166 // HANDLE: $(expr, context)
167 // (which is just equivalent to: $(context).find(expr)
169 return jQuery( context
).find( selector
);
172 // HANDLE: $(function)
173 // Shortcut for document ready
174 } else if ( jQuery
.isFunction( selector
) ) {
175 return rootjQuery
.ready( selector
);
178 if (selector
.selector
!== undefined) {
179 this.selector
= selector
.selector
;
180 this.context
= selector
.context
;
183 return jQuery
.isArray( selector
) ?
184 this.setArray( selector
) :
185 jQuery
.makeArray( selector
, this );
188 // Start with an empty selector
191 // The current version of jQuery being used
194 // The default length of a jQuery object is 0
197 // The number of elements contained in the matched element set
202 toArray: function() {
203 return slice
.call( this, 0 );
206 // Get the Nth element in the matched element set OR
207 // Get the whole matched element set as a clean array
208 get: function( num
) {
211 // Return a 'clean' array
214 // Return just the object
215 ( num
< 0 ? this.slice(num
)[ 0 ] : this[ num
] );
218 // Take an array of elements and push it onto the stack
219 // (returning the new matched element set)
220 pushStack: function( elems
, name
, selector
) {
221 // Build a new jQuery matched element set
222 var ret
= jQuery( elems
|| null );
224 // Add the old object onto the stack (as a reference)
225 ret
.prevObject
= this;
227 ret
.context
= this.context
;
229 if ( name
=== "find" ) {
230 ret
.selector
= this.selector
+ (this.selector
? " " : "") + selector
;
232 ret
.selector
= this.selector
+ "." + name
+ "(" + selector
+ ")";
235 // Return the newly-formed element set
239 // Force the current matched set of elements to become
240 // the specified array of elements (destroying the stack in the process)
241 // You should use pushStack() in order to do this, but maintain the stack
242 setArray: function( elems
) {
243 // Resetting the length to 0, then using the native Array push
244 // is a super-fast way to populate an object with array-like properties
246 push
.apply( this, elems
);
251 // Execute a callback for every element in the matched set.
252 // (You can seed the arguments with an array of args, but this is
253 // only used internally.)
254 each: function( callback
, args
) {
255 return jQuery
.each( this, callback
, args
);
258 ready: function( fn
) {
259 // Attach the listeners
262 // If the DOM is already ready
263 if ( jQuery
.isReady
) {
264 // Execute the function immediately
265 fn
.call( document
, jQuery
);
267 // Otherwise, remember the function for later
268 } else if ( readyList
) {
269 // Add the function to the wait list
270 readyList
.push( fn
);
279 this.slice( i
, +i
+ 1 );
287 return this.eq( -1 );
291 return this.pushStack( slice
.apply( this, arguments
),
292 "slice", slice
.call(arguments
).join(",") );
295 map: function( callback
) {
296 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
297 return callback
.call( elem
, i
, elem
);
302 return this.prevObject
|| jQuery(null);
305 // For internal use only.
306 // Behaves like an Array's method, not like a jQuery method.
312 // Give the init function the jQuery prototype for later instantiation
313 jQuery
.fn
.init
.prototype = jQuery
.fn
;
315 jQuery
.extend
= jQuery
.fn
.extend = function() {
316 // copy reference to target object
317 var target
= arguments
[0] || {}, i
= 1, length
= arguments
.length
, deep
= false, options
, name
, src
, copy
;
319 // Handle a deep copy situation
320 if ( typeof target
=== "boolean" ) {
322 target
= arguments
[1] || {};
323 // skip the boolean and the target
327 // Handle case when target is a string or something (possible in deep copy)
328 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
332 // extend jQuery itself if only one argument is passed
333 if ( length
=== i
) {
338 for ( ; i
< length
; i
++ ) {
339 // Only deal with non-null/undefined values
340 if ( (options
= arguments
[ i
]) != null ) {
341 // Extend the base object
342 for ( name
in options
) {
343 src
= target
[ name
];
344 copy
= options
[ name
];
346 // Prevent never-ending loop
347 if ( target
=== copy
) {
351 // Recurse if we're merging object literal values or arrays
352 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || jQuery
.isArray(copy
) ) ) {
353 var clone
= src
&& ( jQuery
.isPlainObject(src
) || jQuery
.isArray(src
) ) ? src
354 : jQuery
.isArray(copy
) ? [] : {};
356 // Never move original objects, clone them
357 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
359 // Don't bring in undefined values
360 } else if ( copy
!== undefined ) {
361 target
[ name
] = copy
;
367 // Return the modified object
372 noConflict: function( deep
) {
376 window
.jQuery
= _jQuery
;
382 // Is the DOM ready to be used? Set to true once it occurs.
385 // Handle when the DOM is ready
387 // Make sure that the DOM is not already loaded
388 if ( !jQuery
.isReady
) {
389 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
390 if ( !document
.body
) {
391 return setTimeout( jQuery
.ready
, 13 );
394 // Remember that the DOM is ready
395 jQuery
.isReady
= true;
397 // If there are functions bound, to execute
399 // Execute all of them
401 while ( (fn
= readyList
[ i
++ ]) ) {
402 fn
.call( document
, jQuery
);
405 // Reset the list of functions
409 // Trigger any bound ready events
410 if ( jQuery
.fn
.triggerHandler
) {
411 jQuery( document
).triggerHandler( "ready" );
416 bindReady: function() {
423 // Catch cases where $(document).ready() is called after the
424 // browser event has already occurred.
425 if ( document
.readyState
=== "complete" ) {
426 return jQuery
.ready();
429 // Mozilla, Opera and webkit nightlies currently support this event
430 if ( document
.addEventListener
) {
431 // Use the handy event callback
432 document
.addEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
434 // A fallback to window.onload, that will always work
435 window
.addEventListener( "load", jQuery
.ready
, false );
437 // If IE event model is used
438 } else if ( document
.attachEvent
) {
439 // ensure firing before onload,
440 // maybe late but safe also for iframes
441 document
.attachEvent("onreadystatechange", DOMContentLoaded
);
443 // A fallback to window.onload, that will always work
444 window
.attachEvent( "onload", jQuery
.ready
);
446 // If IE and not a frame
447 // continually check to see if the document is ready
448 var toplevel
= false;
451 toplevel
= window
.frameElement
== null;
454 if ( document
.documentElement
.doScroll
&& toplevel
) {
460 // See test/unit/core.js for details concerning isFunction.
461 // Since version 1.3, DOM methods and functions like alert
462 // aren't supported. They return false on IE (#2968).
463 isFunction: function( obj
) {
464 return toString
.call(obj
) === "[object Function]";
467 isArray: function( obj
) {
468 return toString
.call(obj
) === "[object Array]";
471 isPlainObject: function( obj
) {
472 // Must be an Object.
473 // Because of IE, we also have to check the presence of the constructor property.
474 // Make sure that DOM nodes and window objects don't pass through, as well
475 if ( !obj
|| toString
.call(obj
) !== "[object Object]" || obj
.nodeType
|| obj
.setInterval
) {
479 // Not own constructor property must be Object
481 && !hasOwnProperty
.call(obj
, "constructor")
482 && !hasOwnProperty
.call(obj
.constructor.prototype, "isPrototypeOf") ) {
486 // Own properties are enumerated firstly, so to speed up,
487 // if last one is own, then all properties are own.
490 for ( key
in obj
) {}
492 return key
=== undefined || hasOwnProperty
.call( obj
, key
);
495 isEmptyObject: function( obj
) {
496 for ( var name
in obj
) {
502 error: function( msg
) {
506 parseJSON: function( data
) {
507 if ( typeof data
!== "string" || !data
) {
511 // Make sure the incoming data is actual JSON
512 // Logic borrowed from http://json.org/json2.js
513 if ( /^[\],:{}\s]*$/.test(data
.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
514 .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
515 .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
517 // Try to use the native JSON parser first
518 return window
.JSON
&& window
.JSON
.parse
?
519 window
.JSON
.parse( data
) :
520 (new Function("return " + data
))();
523 jQuery
.error( "Invalid JSON: " + data
);
529 // Evalulates a script in a global context
530 globalEval: function( data
) {
531 if ( data
&& rnotwhite
.test(data
) ) {
532 // Inspired by code by Andrea Giammarchi
533 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
534 var head
= document
.getElementsByTagName("head")[0] || document
.documentElement
,
535 script
= document
.createElement("script");
537 script
.type
= "text/javascript";
539 if ( jQuery
.support
.scriptEval
) {
540 script
.appendChild( document
.createTextNode( data
) );
545 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
546 // This arises when a base node is used (#2709).
547 head
.insertBefore( script
, head
.firstChild
);
548 head
.removeChild( script
);
552 nodeName: function( elem
, name
) {
553 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() === name
.toUpperCase();
556 // args is for internal usage only
557 each: function( object
, callback
, args
) {
559 length
= object
.length
,
560 isObj
= length
=== undefined || jQuery
.isFunction(object
);
564 for ( name
in object
) {
565 if ( callback
.apply( object
[ name
], args
) === false ) {
570 for ( ; i
< length
; ) {
571 if ( callback
.apply( object
[ i
++ ], args
) === false ) {
577 // A special, fast, case for the most common use of each
580 for ( name
in object
) {
581 if ( callback
.call( object
[ name
], name
, object
[ name
] ) === false ) {
586 for ( var value
= object
[0];
587 i
< length
&& callback
.call( value
, i
, value
) !== false; value
= object
[++i
] ) {}
594 trim: function( text
) {
595 return (text
|| "").replace( rtrim
, "" );
598 // results is for internal usage only
599 makeArray: function( array
, results
) {
600 var ret
= results
|| [];
602 if ( array
!= null ) {
603 // The window, strings (and functions) also have 'length'
604 // The extra typeof function check is to prevent crashes
605 // in Safari 2 (See: #3039)
606 if ( array
.length
== null || typeof array
=== "string" || jQuery
.isFunction(array
) || (typeof array
!== "function" && array
.setInterval
) ) {
607 push
.call( ret
, array
);
609 jQuery
.merge( ret
, array
);
616 inArray: function( elem
, array
) {
617 if ( array
.indexOf
) {
618 return array
.indexOf( elem
);
621 for ( var i
= 0, length
= array
.length
; i
< length
; i
++ ) {
622 if ( array
[ i
] === elem
) {
630 merge: function( first
, second
) {
631 var i
= first
.length
, j
= 0;
633 if ( typeof second
.length
=== "number" ) {
634 for ( var l
= second
.length
; j
< l
; j
++ ) {
635 first
[ i
++ ] = second
[ j
];
638 while ( second
[j
] !== undefined ) {
639 first
[ i
++ ] = second
[ j
++ ];
648 grep: function( elems
, callback
, inv
) {
651 // Go through the array, only saving the items
652 // that pass the validator function
653 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ ) {
654 if ( !inv
!== !callback( elems
[ i
], i
) ) {
655 ret
.push( elems
[ i
] );
662 // arg is for internal usage only
663 map: function( elems
, callback
, arg
) {
666 // Go through the array, translating each of the items to their
667 // new value (or values).
668 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ ) {
669 value
= callback( elems
[ i
], i
, arg
);
671 if ( value
!= null ) {
672 ret
[ ret
.length
] = value
;
676 return ret
.concat
.apply( [], ret
);
679 // A global GUID counter for objects
682 proxy: function( fn
, proxy
, thisObject
) {
683 if ( arguments
.length
=== 2 ) {
684 if ( typeof proxy
=== "string" ) {
686 fn
= thisObject
[ proxy
];
689 } else if ( proxy
&& !jQuery
.isFunction( proxy
) ) {
695 if ( !proxy
&& fn
) {
697 return fn
.apply( thisObject
|| this, arguments
);
701 // Set the guid of unique handler to the same of original handler, so it can be removed
703 proxy
.guid
= fn
.guid
= fn
.guid
|| proxy
.guid
|| jQuery
.guid
++;
706 // So proxy can be declared as an argument
710 // Use of jQuery.browser is frowned upon.
711 // More details: http://docs.jquery.com/Utilities/jQuery.browser
712 uaMatch: function( ua
) {
713 ua
= ua
.toLowerCase();
715 var match
= /(webkit)[ \/]([\w.]+)/.exec( ua
) ||
716 /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua
) ||
717 /(msie) ([\w.]+)/.exec( ua
) ||
718 !/compatible/.test( ua
) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua
) ||
721 return { browser
: match
[1] || "", version
: match
[2] || "0" };
727 browserMatch
= jQuery
.uaMatch( userAgent
);
728 if ( browserMatch
.browser
) {
729 jQuery
.browser
[ browserMatch
.browser
] = true;
730 jQuery
.browser
.version
= browserMatch
.version
;
733 // Deprecated, use jQuery.browser.webkit instead
734 if ( jQuery
.browser
.webkit
) {
735 jQuery
.browser
.safari
= true;
739 jQuery
.inArray = function( elem
, array
) {
740 return indexOf
.call( array
, elem
);
744 // All jQuery objects should point back to these
745 rootjQuery
= jQuery(document
);
747 // Cleanup functions for the document ready method
748 if ( document
.addEventListener
) {
749 DOMContentLoaded = function() {
750 document
.removeEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
754 } else if ( document
.attachEvent
) {
755 DOMContentLoaded = function() {
756 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
757 if ( document
.readyState
=== "complete" ) {
758 document
.detachEvent( "onreadystatechange", DOMContentLoaded
);
764 // The DOM ready check for Internet Explorer
765 function doScrollCheck() {
766 if ( jQuery
.isReady
) {
771 // If IE is used, use the trick by Diego Perini
772 // http://javascript.nwbox.com/IEContentLoaded/
773 document
.documentElement
.doScroll("left");
775 setTimeout( doScrollCheck
, 1 );
779 // and execute any waiting functions
783 function evalScript( i
, elem
) {
791 jQuery
.globalEval( elem
.text
|| elem
.textContent
|| elem
.innerHTML
|| "" );
794 if ( elem
.parentNode
) {
795 elem
.parentNode
.removeChild( elem
);
799 // Mutifunctional method to get and set values to a collection
800 // The value/s can be optionally by executed if its a function
801 function access( elems
, key
, value
, exec
, fn
, pass
) {
802 var length
= elems
.length
;
804 // Setting many attributes
805 if ( typeof key
=== "object" ) {
806 for ( var k
in key
) {
807 access( elems
, k
, key
[k
], exec
, fn
, value
);
812 // Setting one attribute
813 if ( value
!== undefined ) {
814 // Optionally, function values get executed if exec is true
815 exec
= !pass
&& exec
&& jQuery
.isFunction(value
);
817 for ( var i
= 0; i
< length
; i
++ ) {
818 fn( elems
[i
], key
, exec
? value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) : value
, pass
);
824 // Getting an attribute
825 return length
? fn( elems
[0], key
) : null;
829 return (new Date
).getTime();
835 var root
= document
.documentElement
,
836 script
= document
.createElement("script"),
837 div
= document
.createElement("div"),
838 id
= "script" + now();
840 div
.style
.display
= "none";
841 div
.innerHTML
= " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
843 var all
= div
.getElementsByTagName("*"),
844 a
= div
.getElementsByTagName("a")[0];
846 // Can't get basic test support
847 if ( !all
|| !all
.length
|| !a
) {
852 // IE strips leading whitespace when .innerHTML is used
853 leadingWhitespace
: div
.firstChild
.nodeType
=== 3,
855 // Make sure that tbody elements aren't automatically inserted
856 // IE will insert them into empty tables
857 tbody
: !div
.getElementsByTagName("tbody").length
,
859 // Make sure that link elements get serialized correctly by innerHTML
860 // This requires a wrapper element in IE
861 htmlSerialize
: !!div
.getElementsByTagName("link").length
,
863 // Get the style information from getAttribute
864 // (IE uses .cssText insted)
865 style
: /red/.test( a
.getAttribute("style") ),
867 // Make sure that URLs aren't manipulated
868 // (IE normalizes it by default)
869 hrefNormalized
: a
.getAttribute("href") === "/a",
871 // Make sure that element opacity exists
872 // (IE uses filter instead)
873 // Use a regex to work around a WebKit issue. See #5145
874 opacity
: /^0.55$/.test( a
.style
.opacity
),
876 // Verify style float existence
877 // (IE uses styleFloat instead of cssFloat)
878 cssFloat
: !!a
.style
.cssFloat
,
880 // Make sure that if no value is specified for a checkbox
881 // that it defaults to "on".
882 // (WebKit defaults to "" instead)
883 checkOn
: div
.getElementsByTagName("input")[0].value
=== "on",
885 // Make sure that a selected-by-default option has a working selected property.
886 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
887 optSelected
: document
.createElement("select").appendChild( document
.createElement("option") ).selected
,
889 // Will be defined later
896 script
.type
= "text/javascript";
898 script
.appendChild( document
.createTextNode( "window." + id
+ "=1;" ) );
901 root
.insertBefore( script
, root
.firstChild
);
903 // Make sure that the execution of code works by injecting a script
904 // tag with appendChild/createTextNode
905 // (IE doesn't support this, fails, and uses .text instead)
906 if ( window
[ id
] ) {
907 jQuery
.support
.scriptEval
= true;
911 root
.removeChild( script
);
913 if ( div
.attachEvent
&& div
.fireEvent
) {
914 div
.attachEvent("onclick", function click() {
915 // Cloning a node shouldn't copy over any
916 // bound event handlers (IE does this)
917 jQuery
.support
.noCloneEvent
= false;
918 div
.detachEvent("onclick", click
);
920 div
.cloneNode(true).fireEvent("onclick");
923 div
= document
.createElement("div");
924 div
.innerHTML
= "<input type='radio' name='radiotest' checked='checked'/>";
926 var fragment
= document
.createDocumentFragment();
927 fragment
.appendChild( div
.firstChild
);
929 // WebKit doesn't clone checked state correctly in fragments
930 jQuery
.support
.checkClone
= fragment
.cloneNode(true).cloneNode(true).lastChild
.checked
;
932 // Figure out if the W3C box model works as expected
933 // document.body must exist before we can do this
935 var div
= document
.createElement("div");
936 div
.style
.width
= div
.style
.paddingLeft
= "1px";
938 document
.body
.appendChild( div
);
939 jQuery
.boxModel
= jQuery
.support
.boxModel
= div
.offsetWidth
=== 2;
940 document
.body
.removeChild( div
).style
.display
= 'none';
944 // Technique from Juriy Zaytsev
945 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
946 var eventSupported = function( eventName
) {
947 var el
= document
.createElement("div");
948 eventName
= "on" + eventName
;
950 var isSupported
= (eventName
in el
);
951 if ( !isSupported
) {
952 el
.setAttribute(eventName
, "return;");
953 isSupported
= typeof el
[eventName
] === "function";
960 jQuery
.support
.submitBubbles
= eventSupported("submit");
961 jQuery
.support
.changeBubbles
= eventSupported("change");
963 // release memory in IE
964 root
= script
= div
= all
= a
= null;
969 "class": "className",
970 readonly
: "readOnly",
971 maxlength
: "maxLength",
972 cellspacing
: "cellSpacing",
975 tabindex
: "tabIndex",
977 frameborder
: "frameBorder"
979 var expando
= "jQuery" + now(), uuid
= 0, windowData
= {};
980 var emptyObject
= {};
987 // The following elements throw uncatchable exceptions if you
988 // attempt to add expando properties to them.
995 data: function( elem
, name
, data
) {
996 if ( elem
.nodeName
&& jQuery
.noData
[elem
.nodeName
.toLowerCase()] ) {
1000 elem
= elem
== window
?
1004 var id
= elem
[ expando
], cache
= jQuery
.cache
, thisCache
;
1006 // Handle the case where there's no name immediately
1007 if ( !name
&& !id
) {
1011 // Compute a unique ID for the element
1016 // Avoid generating a new cache unless none exists and we
1017 // want to manipulate it.
1018 if ( typeof name
=== "object" ) {
1019 elem
[ expando
] = id
;
1020 thisCache
= cache
[ id
] = jQuery
.extend(true, {}, name
);
1021 } else if ( cache
[ id
] ) {
1022 thisCache
= cache
[ id
];
1023 } else if ( typeof data
=== "undefined" ) {
1024 thisCache
= emptyObject
;
1026 thisCache
= cache
[ id
] = {};
1029 // Prevent overriding the named cache with undefined values
1030 if ( data
!== undefined ) {
1031 elem
[ expando
] = id
;
1032 thisCache
[ name
] = data
;
1035 return typeof name
=== "string" ? thisCache
[ name
] : thisCache
;
1038 removeData: function( elem
, name
) {
1039 if ( elem
.nodeName
&& jQuery
.noData
[elem
.nodeName
.toLowerCase()] ) {
1043 elem
= elem
== window
?
1047 var id
= elem
[ expando
], cache
= jQuery
.cache
, thisCache
= cache
[ id
];
1049 // If we want to remove a specific section of the element's data
1052 // Remove the section of cache data
1053 delete thisCache
[ name
];
1055 // If we've removed all the data, remove the element's cache
1056 if ( jQuery
.isEmptyObject(thisCache
) ) {
1057 jQuery
.removeData( elem
);
1061 // Otherwise, we want to remove all of the element's data
1063 // Clean up the element expando
1065 delete elem
[ expando
];
1067 // IE has trouble directly removing the expando
1068 // but it's ok with using removeAttribute
1069 if ( elem
.removeAttribute
) {
1070 elem
.removeAttribute( expando
);
1074 // Completely remove the data cache
1081 data: function( key
, value
) {
1082 if ( typeof key
=== "undefined" && this.length
) {
1083 return jQuery
.data( this[0] );
1085 } else if ( typeof key
=== "object" ) {
1086 return this.each(function() {
1087 jQuery
.data( this, key
);
1091 var parts
= key
.split(".");
1092 parts
[1] = parts
[1] ? "." + parts
[1] : "";
1094 if ( value
=== undefined ) {
1095 var data
= this.triggerHandler("getData" + parts
[1] + "!", [parts
[0]]);
1097 if ( data
=== undefined && this.length
) {
1098 data
= jQuery
.data( this[0], key
);
1100 return data
=== undefined && parts
[1] ?
1101 this.data( parts
[0] ) :
1104 return this.trigger("setData" + parts
[1] + "!", [parts
[0], value
]).each(function() {
1105 jQuery
.data( this, key
, value
);
1110 removeData: function( key
) {
1111 return this.each(function() {
1112 jQuery
.removeData( this, key
);
1117 queue: function( elem
, type
, data
) {
1122 type
= (type
|| "fx") + "queue";
1123 var q
= jQuery
.data( elem
, type
);
1125 // Speed up dequeue by getting out quickly if this is just a lookup
1130 if ( !q
|| jQuery
.isArray(data
) ) {
1131 q
= jQuery
.data( elem
, type
, jQuery
.makeArray(data
) );
1140 dequeue: function( elem
, type
) {
1141 type
= type
|| "fx";
1143 var queue
= jQuery
.queue( elem
, type
), fn
= queue
.shift();
1145 // If the fx queue is dequeued, always remove the progress sentinel
1146 if ( fn
=== "inprogress" ) {
1151 // Add a progress sentinel to prevent the fx queue from being
1152 // automatically dequeued
1153 if ( type
=== "fx" ) {
1154 queue
.unshift("inprogress");
1157 fn
.call(elem
, function() {
1158 jQuery
.dequeue(elem
, type
);
1165 queue: function( type
, data
) {
1166 if ( typeof type
!== "string" ) {
1171 if ( data
=== undefined ) {
1172 return jQuery
.queue( this[0], type
);
1174 return this.each(function( i
, elem
) {
1175 var queue
= jQuery
.queue( this, type
, data
);
1177 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
1178 jQuery
.dequeue( this, type
);
1182 dequeue: function( type
) {
1183 return this.each(function() {
1184 jQuery
.dequeue( this, type
);
1188 // Based off of the plugin by Clint Helfers, with permission.
1189 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1190 delay: function( time
, type
) {
1191 time
= jQuery
.fx
? jQuery
.fx
.speeds
[time
] || time
: time
;
1192 type
= type
|| "fx";
1194 return this.queue( type
, function() {
1196 setTimeout(function() {
1197 jQuery
.dequeue( elem
, type
);
1202 clearQueue: function( type
) {
1203 return this.queue( type
|| "fx", [] );
1206 var rclass
= /[\n\t]/g,
1209 rspecialurl
= /href|src|style/,
1210 rtype
= /(button|input)/i,
1211 rfocusable
= /(button|input|object|select|textarea)/i,
1212 rclickable
= /^(a|area)$/i,
1213 rradiocheck
= /radio|checkbox/;
1216 attr: function( name
, value
) {
1217 return access( this, name
, value
, true, jQuery
.attr
);
1220 removeAttr: function( name
, fn
) {
1221 return this.each(function(){
1222 jQuery
.attr( this, name
, "" );
1223 if ( this.nodeType
=== 1 ) {
1224 this.removeAttribute( name
);
1229 addClass: function( value
) {
1230 if ( jQuery
.isFunction(value
) ) {
1231 return this.each(function(i
) {
1232 var self
= jQuery(this);
1233 self
.addClass( value
.call(this, i
, self
.attr("class")) );
1237 if ( value
&& typeof value
=== "string" ) {
1238 var classNames
= (value
|| "").split( rspace
);
1240 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
1243 if ( elem
.nodeType
=== 1 ) {
1244 if ( !elem
.className
) {
1245 elem
.className
= value
;
1248 var className
= " " + elem
.className
+ " ";
1249 for ( var c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
1250 if ( className
.indexOf( " " + classNames
[c
] + " " ) < 0 ) {
1251 elem
.className
+= " " + classNames
[c
];
1262 removeClass: function( value
) {
1263 if ( jQuery
.isFunction(value
) ) {
1264 return this.each(function(i
) {
1265 var self
= jQuery(this);
1266 self
.removeClass( value
.call(this, i
, self
.attr("class")) );
1270 if ( (value
&& typeof value
=== "string") || value
=== undefined ) {
1271 var classNames
= (value
|| "").split(rspace
);
1273 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
1276 if ( elem
.nodeType
=== 1 && elem
.className
) {
1278 var className
= (" " + elem
.className
+ " ").replace(rclass
, " ");
1279 for ( var c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
1280 className
= className
.replace(" " + classNames
[c
] + " ", " ");
1282 elem
.className
= className
.substring(1, className
.length
- 1);
1285 elem
.className
= "";
1294 toggleClass: function( value
, stateVal
) {
1295 var type
= typeof value
, isBool
= typeof stateVal
=== "boolean";
1297 if ( jQuery
.isFunction( value
) ) {
1298 return this.each(function(i
) {
1299 var self
= jQuery(this);
1300 self
.toggleClass( value
.call(this, i
, self
.attr("class"), stateVal
), stateVal
);
1304 return this.each(function() {
1305 if ( type
=== "string" ) {
1306 // toggle individual class names
1307 var className
, i
= 0, self
= jQuery(this),
1309 classNames
= value
.split( rspace
);
1311 while ( (className
= classNames
[ i
++ ]) ) {
1312 // check each className given, space seperated list
1313 state
= isBool
? state
: !self
.hasClass( className
);
1314 self
[ state
? "addClass" : "removeClass" ]( className
);
1317 } else if ( type
=== "undefined" || type
=== "boolean" ) {
1318 if ( this.className
) {
1319 // store className if set
1320 jQuery
.data( this, "__className__", this.className
);
1323 // toggle whole className
1324 this.className
= this.className
|| value
=== false ? "" : jQuery
.data( this, "__className__" ) || "";
1329 hasClass: function( selector
) {
1330 var className
= " " + selector
+ " ";
1331 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
1332 if ( (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) > -1 ) {
1340 val: function( value
) {
1341 if ( value
=== undefined ) {
1345 if ( jQuery
.nodeName( elem
, "option" ) ) {
1346 return (elem
.attributes
.value
|| {}).specified
? elem
.value
: elem
.text
;
1349 // We need to handle select boxes special
1350 if ( jQuery
.nodeName( elem
, "select" ) ) {
1351 var index
= elem
.selectedIndex
,
1353 options
= elem
.options
,
1354 one
= elem
.type
=== "select-one";
1356 // Nothing was selected
1361 // Loop through all the selected options
1362 for ( var i
= one
? index
: 0, max
= one
? index
+ 1 : options
.length
; i
< max
; i
++ ) {
1363 var option
= options
[ i
];
1365 if ( option
.selected
) {
1366 // Get the specifc value for the option
1367 value
= jQuery(option
).val();
1369 // We don't need an array for one selects
1374 // Multi-Selects return an array
1375 values
.push( value
);
1382 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
1383 if ( rradiocheck
.test( elem
.type
) && !jQuery
.support
.checkOn
) {
1384 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
1388 // Everything else, we just grab the value
1389 return (elem
.value
|| "").replace(rreturn
, "");
1396 var isFunction
= jQuery
.isFunction(value
);
1398 return this.each(function(i
) {
1399 var self
= jQuery(this), val
= value
;
1401 if ( this.nodeType
!== 1 ) {
1406 val
= value
.call(this, i
, self
.val());
1409 // Typecast each time if the value is a Function and the appended
1410 // value is therefore different each time.
1411 if ( typeof val
=== "number" ) {
1415 if ( jQuery
.isArray(val
) && rradiocheck
.test( this.type
) ) {
1416 this.checked
= jQuery
.inArray( self
.val(), val
) >= 0;
1418 } else if ( jQuery
.nodeName( this, "select" ) ) {
1419 var values
= jQuery
.makeArray(val
);
1421 jQuery( "option", this ).each(function() {
1422 this.selected
= jQuery
.inArray( jQuery(this).val(), values
) >= 0;
1425 if ( !values
.length
) {
1426 this.selectedIndex
= -1;
1448 attr: function( elem
, name
, value
, pass
) {
1449 // don't set attributes on text and comment nodes
1450 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
1454 if ( pass
&& name
in jQuery
.attrFn
) {
1455 return jQuery(elem
)[name
](value
);
1458 var notxml
= elem
.nodeType
!== 1 || !jQuery
.isXMLDoc( elem
),
1459 // Whether we are setting (or getting)
1460 set = value
!== undefined;
1462 // Try to normalize/fix the name
1463 name
= notxml
&& jQuery
.props
[ name
] || name
;
1465 // Only do all the following if this is a node (faster for style)
1466 if ( elem
.nodeType
=== 1 ) {
1467 // These attributes require special treatment
1468 var special
= rspecialurl
.test( name
);
1470 // Safari mis-reports the default selected property of an option
1471 // Accessing the parent's selectedIndex property fixes it
1472 if ( name
=== "selected" && !jQuery
.support
.optSelected
) {
1473 var parent
= elem
.parentNode
;
1475 parent
.selectedIndex
;
1477 // Make sure that it also works with optgroups, see #5701
1478 if ( parent
.parentNode
) {
1479 parent
.parentNode
.selectedIndex
;
1484 // If applicable, access the attribute via the DOM 0 way
1485 if ( name
in elem
&& notxml
&& !special
) {
1487 // We can't allow the type property to be changed (since it causes problems in IE)
1488 if ( name
=== "type" && rtype
.test( elem
.nodeName
) && elem
.parentNode
) {
1489 jQuery
.error( "type property can't be changed" );
1492 elem
[ name
] = value
;
1495 // browsers index elements by id/name on forms, give priority to attributes.
1496 if ( jQuery
.nodeName( elem
, "form" ) && elem
.getAttributeNode(name
) ) {
1497 return elem
.getAttributeNode( name
).nodeValue
;
1500 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
1501 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
1502 if ( name
=== "tabIndex" ) {
1503 var attributeNode
= elem
.getAttributeNode( "tabIndex" );
1505 return attributeNode
&& attributeNode
.specified
?
1506 attributeNode
.value
:
1507 rfocusable
.test( elem
.nodeName
) || rclickable
.test( elem
.nodeName
) && elem
.href
?
1512 return elem
[ name
];
1515 if ( !jQuery
.support
.style
&& notxml
&& name
=== "style" ) {
1517 elem
.style
.cssText
= "" + value
;
1520 return elem
.style
.cssText
;
1524 // convert the value to a string (all browsers do this but IE) see #1070
1525 elem
.setAttribute( name
, "" + value
);
1528 var attr
= !jQuery
.support
.hrefNormalized
&& notxml
&& special
?
1529 // Some attributes require a special call on IE
1530 elem
.getAttribute( name
, 2 ) :
1531 elem
.getAttribute( name
);
1533 // Non-existent attributes return null, we normalize to undefined
1534 return attr
=== null ? undefined : attr
;
1537 // elem is actually elem.style ... set the style
1538 // Using attr for specific style information is now deprecated. Use style insead.
1539 return jQuery
.style( elem
, name
, value
);
1542 var fcleanup = function( nm
) {
1543 return nm
.replace(/[^\w\s\.\|`]/g, function( ch
) {
1549 * A number of helper functions used for managing events.
1550 * Many of the ideas behind this code originated from
1551 * Dean Edwards' addEvent library.
1555 // Bind an event to an element
1556 // Original by Dean Edwards
1557 add: function( elem
, types
, handler
, data
) {
1558 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
1562 // For whatever reason, IE has trouble passing the window object
1563 // around, causing it to be cloned in the process
1564 if ( elem
.setInterval
&& ( elem
!== window
&& !elem
.frameElement
) ) {
1568 // Make sure that the function being executed has a unique ID
1569 if ( !handler
.guid
) {
1570 handler
.guid
= jQuery
.guid
++;
1573 // if data is passed, bind to handler
1574 if ( data
!== undefined ) {
1575 // Create temporary function pointer to original handler
1578 // Create unique handler function, wrapped around original handler
1579 handler
= jQuery
.proxy( fn
);
1581 // Store data in unique handler
1582 handler
.data
= data
;
1585 // Init the element's event structure
1586 var events
= jQuery
.data( elem
, "events" ) || jQuery
.data( elem
, "events", {} ),
1587 handle
= jQuery
.data( elem
, "handle" ), eventHandle
;
1590 eventHandle = function() {
1591 // Handle the second event of a trigger and when
1592 // an event is called after a page has unloaded
1593 return typeof jQuery
!== "undefined" && !jQuery
.event
.triggered
?
1594 jQuery
.event
.handle
.apply( eventHandle
.elem
, arguments
) :
1598 handle
= jQuery
.data( elem
, "handle", eventHandle
);
1601 // If no handle is found then we must be trying to bind to one of the
1602 // banned noData elements
1607 // Add elem as a property of the handle function
1608 // This is to prevent a memory leak with non-native
1612 // Handle multiple events separated by a space
1613 // jQuery(...).bind("mouseover mouseout", fn);
1614 types
= types
.split( /\s+/ );
1618 while ( (type
= types
[ i
++ ]) ) {
1619 // Namespaced event handlers
1620 var namespaces
= type
.split(".");
1621 type
= namespaces
.shift();
1624 handler
= jQuery
.proxy( handler
);
1626 if ( data
!== undefined ) {
1627 handler
.data
= data
;
1631 handler
.type
= namespaces
.slice(0).sort().join(".");
1633 // Get the current list of functions bound to this event
1634 var handlers
= events
[ type
],
1635 special
= this.special
[ type
] || {};
1637 // Init the event handler queue
1639 handlers
= events
[ type
] = {};
1641 // Check for a special event handler
1642 // Only use addEventListener/attachEvent if the special
1643 // events handler returns false
1644 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, handler
) === false ) {
1645 // Bind the global event handler to the element
1646 if ( elem
.addEventListener
) {
1647 elem
.addEventListener( type
, handle
, false );
1648 } else if ( elem
.attachEvent
) {
1649 elem
.attachEvent( "on" + type
, handle
);
1654 if ( special
.add
) {
1655 var modifiedHandler
= special
.add
.call( elem
, handler
, data
, namespaces
, handlers
);
1656 if ( modifiedHandler
&& jQuery
.isFunction( modifiedHandler
) ) {
1657 modifiedHandler
.guid
= modifiedHandler
.guid
|| handler
.guid
;
1658 modifiedHandler
.data
= modifiedHandler
.data
|| handler
.data
;
1659 modifiedHandler
.type
= modifiedHandler
.type
|| handler
.type
;
1660 handler
= modifiedHandler
;
1664 // Add the function to the element's handler list
1665 handlers
[ handler
.guid
] = handler
;
1667 // Keep track of which events have been used, for global triggering
1668 this.global
[ type
] = true;
1671 // Nullify elem to prevent memory leaks in IE
1677 // Detach an event or set of events from an element
1678 remove: function( elem
, types
, handler
) {
1679 // don't do events on text and comment nodes
1680 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
1684 var events
= jQuery
.data( elem
, "events" ), ret
, type
, fn
;
1687 // Unbind all events for the element
1688 if ( types
=== undefined || (typeof types
=== "string" && types
.charAt(0) === ".") ) {
1689 for ( type
in events
) {
1690 this.remove( elem
, type
+ (types
|| "") );
1693 // types is actually an event object here
1695 handler
= types
.handler
;
1699 // Handle multiple events separated by a space
1700 // jQuery(...).unbind("mouseover mouseout", fn);
1701 types
= types
.split(/\s+/);
1703 while ( (type
= types
[ i
++ ]) ) {
1704 // Namespaced event handlers
1705 var namespaces
= type
.split(".");
1706 type
= namespaces
.shift();
1707 var all
= !namespaces
.length
,
1708 cleaned
= jQuery
.map( namespaces
.slice(0).sort(), fcleanup
),
1709 namespace = new RegExp("(^|\\.)" + cleaned
.join("\\.(?:.*\\.)?") + "(\\.|$)"),
1710 special
= this.special
[ type
] || {};
1712 if ( events
[ type
] ) {
1713 // remove the given handler for the given type
1715 fn
= events
[ type
][ handler
.guid
];
1716 delete events
[ type
][ handler
.guid
];
1718 // remove all handlers for the given type
1720 for ( var handle
in events
[ type
] ) {
1721 // Handle the removal of namespaced events
1722 if ( all
|| namespace.test( events
[ type
][ handle
].type
) ) {
1723 delete events
[ type
][ handle
];
1728 if ( special
.remove
) {
1729 special
.remove
.call( elem
, namespaces
, fn
);
1732 // remove generic event handler if no more handlers exist
1733 for ( ret
in events
[ type
] ) {
1737 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
) === false ) {
1738 if ( elem
.removeEventListener
) {
1739 elem
.removeEventListener( type
, jQuery
.data( elem
, "handle" ), false );
1740 } else if ( elem
.detachEvent
) {
1741 elem
.detachEvent( "on" + type
, jQuery
.data( elem
, "handle" ) );
1745 delete events
[ type
];
1751 // Remove the expando if it's no longer used
1752 for ( ret
in events
) {
1756 var handle
= jQuery
.data( elem
, "handle" );
1760 jQuery
.removeData( elem
, "events" );
1761 jQuery
.removeData( elem
, "handle" );
1766 // bubbling is internal
1767 trigger: function( event
, data
, elem
/*, bubbling */ ) {
1768 // Event object or event type
1769 var type
= event
.type
|| event
,
1770 bubbling
= arguments
[3];
1773 event
= typeof event
=== "object" ?
1774 // jQuery.Event object
1775 event
[expando
] ? event
:
1777 jQuery
.extend( jQuery
.Event(type
), event
) :
1778 // Just the event type (string)
1781 if ( type
.indexOf("!") >= 0 ) {
1782 event
.type
= type
= type
.slice(0, -1);
1783 event
.exclusive
= true;
1786 // Handle a global trigger
1788 // Don't bubble custom events when global (to avoid too much overhead)
1789 event
.stopPropagation();
1791 // Only trigger if we've ever bound an event for it
1792 if ( this.global
[ type
] ) {
1793 jQuery
.each( jQuery
.cache
, function() {
1794 if ( this.events
&& this.events
[type
] ) {
1795 jQuery
.event
.trigger( event
, data
, this.handle
.elem
);
1801 // Handle triggering a single element
1803 // don't do events on text and comment nodes
1804 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
1808 // Clean up in case it is reused
1809 event
.result
= undefined;
1810 event
.target
= elem
;
1812 // Clone the incoming data, if any
1813 data
= jQuery
.makeArray( data
);
1814 data
.unshift( event
);
1817 event
.currentTarget
= elem
;
1819 // Trigger the event, it is assumed that "handle" is a function
1820 var handle
= jQuery
.data( elem
, "handle" );
1822 handle
.apply( elem
, data
);
1825 var parent
= elem
.parentNode
|| elem
.ownerDocument
;
1827 // Trigger an inline bound script
1829 if ( !(elem
&& elem
.nodeName
&& jQuery
.noData
[elem
.nodeName
.toLowerCase()]) ) {
1830 if ( elem
[ "on" + type
] && elem
[ "on" + type
].apply( elem
, data
) === false ) {
1831 event
.result
= false;
1835 // prevent IE from throwing an error for some elements with some event types, see #3533
1838 if ( !event
.isPropagationStopped() && parent
) {
1839 jQuery
.event
.trigger( event
, data
, parent
, true );
1841 } else if ( !event
.isDefaultPrevented() ) {
1842 var target
= event
.target
, old
,
1843 isClick
= jQuery
.nodeName(target
, "a") && type
=== "click";
1845 if ( !isClick
&& !(target
&& target
.nodeName
&& jQuery
.noData
[target
.nodeName
.toLowerCase()]) ) {
1847 if ( target
[ type
] ) {
1848 // Make sure that we don't accidentally re-trigger the onFOO events
1849 old
= target
[ "on" + type
];
1852 target
[ "on" + type
] = null;
1855 this.triggered
= true;
1859 // prevent IE from throwing an error for some elements with some event types, see #3533
1863 target
[ "on" + type
] = old
;
1866 this.triggered
= false;
1871 handle: function( event
) {
1872 // returned undefined or false
1875 event
= arguments
[0] = jQuery
.event
.fix( event
|| window
.event
);
1876 event
.currentTarget
= this;
1878 // Namespaced event handlers
1879 var namespaces
= event
.type
.split(".");
1880 event
.type
= namespaces
.shift();
1882 // Cache this now, all = true means, any handler
1883 all
= !namespaces
.length
&& !event
.exclusive
;
1885 var namespace = new RegExp("(^|\\.)" + namespaces
.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
1887 handlers
= ( jQuery
.data(this, "events") || {} )[ event
.type
];
1889 for ( var j
in handlers
) {
1890 var handler
= handlers
[ j
];
1892 // Filter the functions by class
1893 if ( all
|| namespace.test(handler
.type
) ) {
1894 // Pass in a reference to the handler function itself
1895 // So that we can later remove it
1896 event
.handler
= handler
;
1897 event
.data
= handler
.data
;
1899 var ret
= handler
.apply( this, arguments
);
1901 if ( ret
!== undefined ) {
1903 if ( ret
=== false ) {
1904 event
.preventDefault();
1905 event
.stopPropagation();
1909 if ( event
.isImmediatePropagationStopped() ) {
1916 return event
.result
;
1919 props
: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
1921 fix: function( event
) {
1922 if ( event
[ expando
] ) {
1926 // store a copy of the original event object
1927 // and "clone" to set read-only properties
1928 var originalEvent
= event
;
1929 event
= jQuery
.Event( originalEvent
);
1931 for ( var i
= this.props
.length
, prop
; i
; ) {
1932 prop
= this.props
[ --i
];
1933 event
[ prop
] = originalEvent
[ prop
];
1936 // Fix target property, if necessary
1937 if ( !event
.target
) {
1938 event
.target
= event
.srcElement
|| document
; // Fixes #1925 where srcElement might not be defined either
1941 // check if target is a textnode (safari)
1942 if ( event
.target
.nodeType
=== 3 ) {
1943 event
.target
= event
.target
.parentNode
;
1946 // Add relatedTarget, if necessary
1947 if ( !event
.relatedTarget
&& event
.fromElement
) {
1948 event
.relatedTarget
= event
.fromElement
=== event
.target
? event
.toElement
: event
.fromElement
;
1951 // Calculate pageX/Y if missing and clientX/Y available
1952 if ( event
.pageX
== null && event
.clientX
!= null ) {
1953 var doc
= document
.documentElement
, body
= document
.body
;
1954 event
.pageX
= event
.clientX
+ (doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0) - (doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0);
1955 event
.pageY
= event
.clientY
+ (doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0) - (doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0);
1958 // Add which for key events
1959 if ( !event
.which
&& ((event
.charCode
|| event
.charCode
=== 0) ? event
.charCode
: event
.keyCode
) ) {
1960 event
.which
= event
.charCode
|| event
.keyCode
;
1963 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
1964 if ( !event
.metaKey
&& event
.ctrlKey
) {
1965 event
.metaKey
= event
.ctrlKey
;
1968 // Add which for click: 1 === left; 2 === middle; 3 === right
1969 // Note: button is not normalized, so don't use it
1970 if ( !event
.which
&& event
.button
!== undefined ) {
1971 event
.which
= (event
.button
& 1 ? 1 : ( event
.button
& 2 ? 3 : ( event
.button
& 4 ? 2 : 0 ) ));
1977 // Deprecated, use jQuery.guid instead
1980 // Deprecated, use jQuery.proxy instead
1981 proxy
: jQuery
.proxy
,
1985 // Make sure the ready event is setup
1986 setup
: jQuery
.bindReady
,
1987 teardown
: jQuery
.noop
1991 add: function( proxy
, data
, namespaces
, live
) {
1992 jQuery
.extend( proxy
, data
|| {} );
1994 proxy
.guid
+= data
.selector
+ data
.live
;
1995 data
.liveProxy
= proxy
;
1997 jQuery
.event
.add( this, data
.live
, liveHandler
, data
);
2001 remove: function( namespaces
) {
2002 if ( namespaces
.length
) {
2003 var remove
= 0, name
= new RegExp("(^|\\.)" + namespaces
[0] + "(\\.|$)");
2005 jQuery
.each( (jQuery
.data(this, "events").live
|| {}), function() {
2006 if ( name
.test(this.type
) ) {
2012 jQuery
.event
.remove( this, namespaces
[0], liveHandler
);
2019 setup: function( data
, namespaces
, fn
) {
2020 // We only want to do this special case on windows
2021 if ( this.setInterval
) {
2022 this.onbeforeunload
= fn
;
2027 teardown: function( namespaces
, fn
) {
2028 if ( this.onbeforeunload
=== fn
) {
2029 this.onbeforeunload
= null;
2036 jQuery
.Event = function( src
) {
2037 // Allow instantiation without the 'new' keyword
2038 if ( !this.preventDefault
) {
2039 return new jQuery
.Event( src
);
2043 if ( src
&& src
.type
) {
2044 this.originalEvent
= src
;
2045 this.type
= src
.type
;
2051 // timeStamp is buggy for some events on Firefox(#3843)
2052 // So we won't rely on the native value
2053 this.timeStamp
= now();
2056 this[ expando
] = true;
2059 function returnFalse() {
2062 function returnTrue() {
2066 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
2067 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
2068 jQuery
.Event
.prototype = {
2069 preventDefault: function() {
2070 this.isDefaultPrevented
= returnTrue
;
2072 var e
= this.originalEvent
;
2077 // if preventDefault exists run it on the original event
2078 if ( e
.preventDefault
) {
2081 // otherwise set the returnValue property of the original event to false (IE)
2082 e
.returnValue
= false;
2084 stopPropagation: function() {
2085 this.isPropagationStopped
= returnTrue
;
2087 var e
= this.originalEvent
;
2091 // if stopPropagation exists run it on the original event
2092 if ( e
.stopPropagation
) {
2093 e
.stopPropagation();
2095 // otherwise set the cancelBubble property of the original event to true (IE)
2096 e
.cancelBubble
= true;
2098 stopImmediatePropagation: function() {
2099 this.isImmediatePropagationStopped
= returnTrue
;
2100 this.stopPropagation();
2102 isDefaultPrevented
: returnFalse
,
2103 isPropagationStopped
: returnFalse
,
2104 isImmediatePropagationStopped
: returnFalse
2107 // Checks if an event happened on an element within another element
2108 // Used in jQuery.event.special.mouseenter and mouseleave handlers
2109 var withinElement = function( event
) {
2110 // Check if mouse(over|out) are still within the same parent element
2111 var parent
= event
.relatedTarget
;
2113 // Traverse up the tree
2114 while ( parent
&& parent
!== this ) {
2115 // Firefox sometimes assigns relatedTarget a XUL element
2116 // which we cannot access the parentNode property of
2118 parent
= parent
.parentNode
;
2120 // assuming we've left the element since we most likely mousedover a xul element
2126 if ( parent
!== this ) {
2127 // set the correct event type
2128 event
.type
= event
.data
;
2130 // handle event if we actually just moused on to a non sub-element
2131 jQuery
.event
.handle
.apply( this, arguments
);
2136 // In case of event delegation, we only need to rename the event.type,
2137 // liveHandler will take care of the rest.
2138 delegate = function( event
) {
2139 event
.type
= event
.data
;
2140 jQuery
.event
.handle
.apply( this, arguments
);
2143 // Create mouseenter and mouseleave events
2145 mouseenter
: "mouseover",
2146 mouseleave
: "mouseout"
2147 }, function( orig
, fix
) {
2148 jQuery
.event
.special
[ orig
] = {
2149 setup: function( data
) {
2150 jQuery
.event
.add( this, fix
, data
&& data
.selector
? delegate
: withinElement
, orig
);
2152 teardown: function( data
) {
2153 jQuery
.event
.remove( this, fix
, data
&& data
.selector
? delegate
: withinElement
);
2158 // submit delegation
2159 if ( !jQuery
.support
.submitBubbles
) {
2161 jQuery
.event
.special
.submit
= {
2162 setup: function( data
, namespaces
, fn
) {
2163 if ( this.nodeName
.toLowerCase() !== "form" ) {
2164 jQuery
.event
.add(this, "click.specialSubmit." + fn
.guid
, function( e
) {
2165 var elem
= e
.target
, type
= elem
.type
;
2167 if ( (type
=== "submit" || type
=== "image") && jQuery( elem
).closest("form").length
) {
2168 return trigger( "submit", this, arguments
);
2172 jQuery
.event
.add(this, "keypress.specialSubmit." + fn
.guid
, function( e
) {
2173 var elem
= e
.target
, type
= elem
.type
;
2175 if ( (type
=== "text" || type
=== "password") && jQuery( elem
).closest("form").length
&& e
.keyCode
=== 13 ) {
2176 return trigger( "submit", this, arguments
);
2185 remove: function( namespaces
, fn
) {
2186 jQuery
.event
.remove( this, "click.specialSubmit" + (fn
? "."+fn
.guid
: "") );
2187 jQuery
.event
.remove( this, "keypress.specialSubmit" + (fn
? "."+fn
.guid
: "") );
2193 // change delegation, happens here so we have bind.
2194 if ( !jQuery
.support
.changeBubbles
) {
2196 var formElems
= /textarea|input|select/i;
2198 function getVal( elem
) {
2199 var type
= elem
.type
, val
= elem
.value
;
2201 if ( type
=== "radio" || type
=== "checkbox" ) {
2204 } else if ( type
=== "select-multiple" ) {
2205 val
= elem
.selectedIndex
> -1 ?
2206 jQuery
.map( elem
.options
, function( elem
) {
2207 return elem
.selected
;
2211 } else if ( elem
.nodeName
.toLowerCase() === "select" ) {
2212 val
= elem
.selectedIndex
;
2218 function testChange( e
) {
2219 var elem
= e
.target
, data
, val
;
2221 if ( !formElems
.test( elem
.nodeName
) || elem
.readOnly
) {
2225 data
= jQuery
.data( elem
, "_change_data" );
2228 // the current data will be also retrieved by beforeactivate
2229 if ( e
.type
!== "focusout" || elem
.type
!== "radio" ) {
2230 jQuery
.data( elem
, "_change_data", val
);
2233 if ( data
=== undefined || val
=== data
) {
2237 if ( data
!= null || val
) {
2239 return jQuery
.event
.trigger( e
, arguments
[1], elem
);
2243 jQuery
.event
.special
.change
= {
2245 focusout
: testChange
,
2247 click: function( e
) {
2248 var elem
= e
.target
, type
= elem
.type
;
2250 if ( type
=== "radio" || type
=== "checkbox" || elem
.nodeName
.toLowerCase() === "select" ) {
2251 return testChange
.call( this, e
);
2255 // Change has to be called before submit
2256 // Keydown will be called before keypress, which is used in submit-event delegation
2257 keydown: function( e
) {
2258 var elem
= e
.target
, type
= elem
.type
;
2260 if ( (e
.keyCode
=== 13 && elem
.nodeName
.toLowerCase() !== "textarea") ||
2261 (e
.keyCode
=== 32 && (type
=== "checkbox" || type
=== "radio")) ||
2262 type
=== "select-multiple" ) {
2263 return testChange
.call( this, e
);
2267 // Beforeactivate happens also before the previous element is blurred
2268 // with this event you can't trigger a change event, but you can store
2269 // information/focus[in] is not needed anymore
2270 beforeactivate: function( e
) {
2271 var elem
= e
.target
;
2273 if ( elem
.nodeName
.toLowerCase() === "input" && elem
.type
=== "radio" ) {
2274 jQuery
.data( elem
, "_change_data", getVal(elem
) );
2278 setup: function( data
, namespaces
, fn
) {
2279 for ( var type
in changeFilters
) {
2280 jQuery
.event
.add( this, type
+ ".specialChange." + fn
.guid
, changeFilters
[type
] );
2283 return formElems
.test( this.nodeName
);
2285 remove: function( namespaces
, fn
) {
2286 for ( var type
in changeFilters
) {
2287 jQuery
.event
.remove( this, type
+ ".specialChange" + (fn
? "."+fn
.guid
: ""), changeFilters
[type
] );
2290 return formElems
.test( this.nodeName
);
2294 var changeFilters
= jQuery
.event
.special
.change
.filters
;
2298 function trigger( type
, elem
, args
) {
2299 args
[0].type
= type
;
2300 return jQuery
.event
.handle
.apply( elem
, args
);
2303 // Create "bubbling" focus and blur events
2304 if ( document
.addEventListener
) {
2305 jQuery
.each({ focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
2306 jQuery
.event
.special
[ fix
] = {
2308 this.addEventListener( orig
, handler
, true );
2310 teardown: function() {
2311 this.removeEventListener( orig
, handler
, true );
2315 function handler( e
) {
2316 e
= jQuery
.event
.fix( e
);
2318 return jQuery
.event
.handle
.call( this, e
);
2323 jQuery
.each(["bind", "one"], function( i
, name
) {
2324 jQuery
.fn
[ name
] = function( type
, data
, fn
) {
2325 // Handle object literals
2326 if ( typeof type
=== "object" ) {
2327 for ( var key
in type
) {
2328 this[ name
](key
, data
, type
[key
], fn
);
2333 if ( jQuery
.isFunction( data
) ) {
2338 var handler
= name
=== "one" ? jQuery
.proxy( fn
, function( event
) {
2339 jQuery( this ).unbind( event
, handler
);
2340 return fn
.apply( this, arguments
);
2343 return type
=== "unload" && name
!== "one" ?
2344 this.one( type
, data
, fn
) :
2345 this.each(function() {
2346 jQuery
.event
.add( this, type
, handler
, data
);
2352 unbind: function( type
, fn
) {
2353 // Handle object literals
2354 if ( typeof type
=== "object" && !type
.preventDefault
) {
2355 for ( var key
in type
) {
2356 this.unbind(key
, type
[key
]);
2361 return this.each(function() {
2362 jQuery
.event
.remove( this, type
, fn
);
2365 trigger: function( type
, data
) {
2366 return this.each(function() {
2367 jQuery
.event
.trigger( type
, data
, this );
2371 triggerHandler: function( type
, data
) {
2373 var event
= jQuery
.Event( type
);
2374 event
.preventDefault();
2375 event
.stopPropagation();
2376 jQuery
.event
.trigger( event
, data
, this[0] );
2377 return event
.result
;
2381 toggle: function( fn
) {
2382 // Save reference to arguments for access in closure
2383 var args
= arguments
, i
= 1;
2385 // link all the functions, so any of them can unbind this click handler
2386 while ( i
< args
.length
) {
2387 jQuery
.proxy( fn
, args
[ i
++ ] );
2390 return this.click( jQuery
.proxy( fn
, function( event
) {
2391 // Figure out which function to execute
2392 var lastToggle
= ( jQuery
.data( this, "lastToggle" + fn
.guid
) || 0 ) % i
;
2393 jQuery
.data( this, "lastToggle" + fn
.guid
, lastToggle
+ 1 );
2395 // Make sure that clicks stop
2396 event
.preventDefault();
2398 // and execute the function
2399 return args
[ lastToggle
].apply( this, arguments
) || false;
2403 hover: function( fnOver
, fnOut
) {
2404 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
2408 jQuery
.each(["live", "die"], function( i
, name
) {
2409 jQuery
.fn
[ name
] = function( types
, data
, fn
) {
2412 if ( jQuery
.isFunction( data
) ) {
2417 types
= (types
|| "").split( /\s+/ );
2419 while ( (type
= types
[ i
++ ]) != null ) {
2420 type
= type
=== "focus" ? "focusin" : // focus --> focusin
2421 type
=== "blur" ? "focusout" : // blur --> focusout
2422 type
=== "hover" ? types
.push("mouseleave") && "mouseenter" : // hover support
2425 if ( name
=== "live" ) {
2426 // bind live handler
2427 jQuery( this.context
).bind( liveConvert( type
, this.selector
), {
2428 data
: data
, selector
: this.selector
, live
: type
2432 // unbind live handler
2433 jQuery( this.context
).unbind( liveConvert( type
, this.selector
), fn
? { guid
: fn
.guid
+ this.selector
+ type
} : null );
2441 function liveHandler( event
) {
2442 var stop
, elems
= [], selectors
= [], args
= arguments
,
2443 related
, match
, fn
, elem
, j
, i
, l
, data
,
2444 live
= jQuery
.extend({}, jQuery
.data( this, "events" ).live
);
2446 // Make sure we avoid non-left-click bubbling in Firefox (#3861)
2447 if ( event
.button
&& event
.type
=== "click" ) {
2453 if ( fn
.live
=== event
.type
||
2454 fn
.altLive
&& jQuery
.inArray(event
.type
, fn
.altLive
) > -1 ) {
2457 if ( !(data
.beforeFilter
&& data
.beforeFilter
[event
.type
] &&
2458 !data
.beforeFilter
[event
.type
](event
)) ) {
2459 selectors
.push( fn
.selector
);
2466 match
= jQuery( event
.target
).closest( selectors
, event
.currentTarget
);
2468 for ( i
= 0, l
= match
.length
; i
< l
; i
++ ) {
2471 elem
= match
[i
].elem
;
2474 if ( match
[i
].selector
=== fn
.selector
) {
2475 // Those two events require additional checking
2476 if ( fn
.live
=== "mouseenter" || fn
.live
=== "mouseleave" ) {
2477 related
= jQuery( event
.relatedTarget
).closest( fn
.selector
)[0];
2480 if ( !related
|| related
!== elem
) {
2481 elems
.push({ elem
: elem
, fn
: fn
});
2487 for ( i
= 0, l
= elems
.length
; i
< l
; i
++ ) {
2489 event
.currentTarget
= match
.elem
;
2490 event
.data
= match
.fn
.data
;
2491 if ( match
.fn
.apply( match
.elem
, args
) === false ) {
2500 function liveConvert( type
, selector
) {
2501 return "live." + (type
? type
+ "." : "") + selector
.replace(/\./g, "`").replace(/ /g
, "&");
2504 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
2505 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
2506 "change select submit keydown keypress keyup error").split(" "), function( i
, name
) {
2508 // Handle event binding
2509 jQuery
.fn
[ name
] = function( fn
) {
2510 return fn
? this.bind( name
, fn
) : this.trigger( name
);
2513 if ( jQuery
.attrFn
) {
2514 jQuery
.attrFn
[ name
] = true;
2518 // Prevent memory leaks in IE
2519 // Window isn't included so as not to unbind existing unload events
2521 // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
2522 if ( window
.attachEvent
&& !window
.addEventListener
) {
2523 window
.attachEvent("onunload", function() {
2524 for ( var id
in jQuery
.cache
) {
2525 if ( jQuery
.cache
[ id
].handle
) {
2526 // Try/Catch is to handle iframes being unloaded, see #4280
2528 jQuery
.event
.remove( jQuery
.cache
[ id
].handle
.elem
);
2535 * Sizzle CSS Selector Engine - v1.0
2536 * Copyright 2009, The Dojo Foundation
2537 * More information: http://sizzlejs.com/
2539 * Permission is hereby granted, free of charge, to any person obtaining
2540 * a copy of this software and associated documentation files (the
2541 * "Software"), to deal in the Software without restriction, including
2542 * without limitation the rights to use, copy, modify, merge, publish,
2543 * distribute, sublicense, and/or sell copies of the Software, and to
2544 * permit persons to whom the Software is furnished to do so, subject to
2545 * the following conditions:
2547 * The above copyright notice and this permission notice shall be
2548 * included in all copies or substantial portions of the Software.
2550 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2551 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2552 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2553 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2554 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2555 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2556 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2560 var chunker
= /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
2562 toString
= Object
.prototype.toString
,
2563 hasDuplicate
= false,
2564 baseHasDuplicate
= true;
2566 // Here we check if the JavaScript engine is using some sort of
2567 // optimization where it does not always call our comparision
2568 // function. If that is the case, discard the hasDuplicate value.
2569 // Thus far that includes Google Chrome.
2570 [0, 0].sort(function(){
2571 baseHasDuplicate
= false;
2575 var Sizzle = function(selector
, context
, results
, seed
) {
2576 results
= results
|| [];
2577 var origContext
= context
= context
|| document
;
2579 if ( context
.nodeType
!== 1 && context
.nodeType
!== 9 ) {
2583 if ( !selector
|| typeof selector
!== "string" ) {
2587 var parts
= [], m
, set, checkSet
, extra
, prune
= true, contextXML
= isXML(context
),
2590 // Reset the position of the chunker regexp (start from head)
2591 while ( (chunker
.exec(""), m
= chunker
.exec(soFar
)) !== null ) {
2602 if ( parts
.length
> 1 && origPOS
.exec( selector
) ) {
2603 if ( parts
.length
=== 2 && Expr
.relative
[ parts
[0] ] ) {
2604 set = posProcess( parts
[0] + parts
[1], context
);
2606 set = Expr
.relative
[ parts
[0] ] ?
2608 Sizzle( parts
.shift(), context
);
2610 while ( parts
.length
) {
2611 selector
= parts
.shift();
2613 if ( Expr
.relative
[ selector
] ) {
2614 selector
+= parts
.shift();
2617 set = posProcess( selector
, set );
2621 // Take a shortcut and set the context if the root selector is an ID
2622 // (but not if it'll be faster if the inner selector is an ID)
2623 if ( !seed
&& parts
.length
> 1 && context
.nodeType
=== 9 && !contextXML
&&
2624 Expr
.match
.ID
.test(parts
[0]) && !Expr
.match
.ID
.test(parts
[parts
.length
- 1]) ) {
2625 var ret
= Sizzle
.find( parts
.shift(), context
, contextXML
);
2626 context
= ret
.expr
? Sizzle
.filter( ret
.expr
, ret
.set )[0] : ret
.set[0];
2631 { expr
: parts
.pop(), set: makeArray(seed
) } :
2632 Sizzle
.find( parts
.pop(), parts
.length
=== 1 && (parts
[0] === "~" || parts
[0] === "+") && context
.parentNode
? context
.parentNode
: context
, contextXML
);
2633 set = ret
.expr
? Sizzle
.filter( ret
.expr
, ret
.set ) : ret
.set;
2635 if ( parts
.length
> 0 ) {
2636 checkSet
= makeArray(set);
2641 while ( parts
.length
) {
2642 var cur
= parts
.pop(), pop
= cur
;
2644 if ( !Expr
.relative
[ cur
] ) {
2650 if ( pop
== null ) {
2654 Expr
.relative
[ cur
]( checkSet
, pop
, contextXML
);
2657 checkSet
= parts
= [];
2666 Sizzle
.error( cur
|| selector
);
2669 if ( toString
.call(checkSet
) === "[object Array]" ) {
2671 results
.push
.apply( results
, checkSet
);
2672 } else if ( context
&& context
.nodeType
=== 1 ) {
2673 for ( var i
= 0; checkSet
[i
] != null; i
++ ) {
2674 if ( checkSet
[i
] && (checkSet
[i
] === true || checkSet
[i
].nodeType
=== 1 && contains(context
, checkSet
[i
])) ) {
2675 results
.push( set[i
] );
2679 for ( var i
= 0; checkSet
[i
] != null; i
++ ) {
2680 if ( checkSet
[i
] && checkSet
[i
].nodeType
=== 1 ) {
2681 results
.push( set[i
] );
2686 makeArray( checkSet
, results
);
2690 Sizzle( extra
, origContext
, results
, seed
);
2691 Sizzle
.uniqueSort( results
);
2697 Sizzle
.uniqueSort = function(results
){
2699 hasDuplicate
= baseHasDuplicate
;
2700 results
.sort(sortOrder
);
2702 if ( hasDuplicate
) {
2703 for ( var i
= 1; i
< results
.length
; i
++ ) {
2704 if ( results
[i
] === results
[i
-1] ) {
2705 results
.splice(i
--, 1);
2714 Sizzle
.matches = function(expr
, set){
2715 return Sizzle(expr
, null, null, set);
2718 Sizzle
.find = function(expr
, context
, isXML
){
2725 for ( var i
= 0, l
= Expr
.order
.length
; i
< l
; i
++ ) {
2726 var type
= Expr
.order
[i
], match
;
2728 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) ) {
2729 var left
= match
[1];
2732 if ( left
.substr( left
.length
- 1 ) !== "\\" ) {
2733 match
[1] = (match
[1] || "").replace(/\\/g
, "");
2734 set = Expr
.find
[ type
]( match
, context
, isXML
);
2735 if ( set != null ) {
2736 expr
= expr
.replace( Expr
.match
[ type
], "" );
2744 set = context
.getElementsByTagName("*");
2747 return {set: set, expr
: expr
};
2750 Sizzle
.filter = function(expr
, set, inplace
, not
){
2751 var old
= expr
, result
= [], curLoop
= set, match
, anyFound
,
2752 isXMLFilter
= set && set[0] && isXML(set[0]);
2754 while ( expr
&& set.length
) {
2755 for ( var type
in Expr
.filter
) {
2756 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) != null && match
[2] ) {
2757 var filter
= Expr
.filter
[ type
], found
, item
, left
= match
[1];
2762 if ( left
.substr( left
.length
- 1 ) === "\\" ) {
2766 if ( curLoop
=== result
) {
2770 if ( Expr
.preFilter
[ type
] ) {
2771 match
= Expr
.preFilter
[ type
]( match
, curLoop
, inplace
, result
, not
, isXMLFilter
);
2774 anyFound
= found
= true;
2775 } else if ( match
=== true ) {
2781 for ( var i
= 0; (item
= curLoop
[i
]) != null; i
++ ) {
2783 found
= filter( item
, match
, i
, curLoop
);
2784 var pass
= not
^ !!found
;
2786 if ( inplace
&& found
!= null ) {
2792 } else if ( pass
) {
2793 result
.push( item
);
2800 if ( found
!== undefined ) {
2805 expr
= expr
.replace( Expr
.match
[ type
], "" );
2816 // Improper expression
2817 if ( expr
=== old
) {
2818 if ( anyFound
== null ) {
2819 Sizzle
.error( expr
);
2831 Sizzle
.error = function( msg
) {
2832 throw "Syntax error, unrecognized expression: " + msg
;
2835 var Expr
= Sizzle
.selectors
= {
2836 order
: [ "ID", "NAME", "TAG" ],
2838 ID
: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
2839 CLASS
: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
2840 NAME
: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
2841 ATTR
: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
2842 TAG
: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
2843 CHILD
: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
2844 POS
: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
2845 PSEUDO
: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
2849 "class": "className",
2853 href: function(elem
){
2854 return elem
.getAttribute("href");
2858 "+": function(checkSet
, part
){
2859 var isPartStr
= typeof part
=== "string",
2860 isTag
= isPartStr
&& !/\W/.test(part
),
2861 isPartStrNotTag
= isPartStr
&& !isTag
;
2864 part
= part
.toLowerCase();
2867 for ( var i
= 0, l
= checkSet
.length
, elem
; i
< l
; i
++ ) {
2868 if ( (elem
= checkSet
[i
]) ) {
2869 while ( (elem
= elem
.previousSibling
) && elem
.nodeType
!== 1 ) {}
2871 checkSet
[i
] = isPartStrNotTag
|| elem
&& elem
.nodeName
.toLowerCase() === part
?
2877 if ( isPartStrNotTag
) {
2878 Sizzle
.filter( part
, checkSet
, true );
2881 ">": function(checkSet
, part
){
2882 var isPartStr
= typeof part
=== "string";
2884 if ( isPartStr
&& !/\W/.test(part
) ) {
2885 part
= part
.toLowerCase();
2887 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
2888 var elem
= checkSet
[i
];
2890 var parent
= elem
.parentNode
;
2891 checkSet
[i
] = parent
.nodeName
.toLowerCase() === part
? parent
: false;
2895 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
2896 var elem
= checkSet
[i
];
2898 checkSet
[i
] = isPartStr
?
2900 elem
.parentNode
=== part
;
2905 Sizzle
.filter( part
, checkSet
, true );
2909 "": function(checkSet
, part
, isXML
){
2910 var doneName
= done
++, checkFn
= dirCheck
;
2912 if ( typeof part
=== "string" && !/\W/.test(part
) ) {
2913 var nodeCheck
= part
= part
.toLowerCase();
2914 checkFn
= dirNodeCheck
;
2917 checkFn("parentNode", part
, doneName
, checkSet
, nodeCheck
, isXML
);
2919 "~": function(checkSet
, part
, isXML
){
2920 var doneName
= done
++, checkFn
= dirCheck
;
2922 if ( typeof part
=== "string" && !/\W/.test(part
) ) {
2923 var nodeCheck
= part
= part
.toLowerCase();
2924 checkFn
= dirNodeCheck
;
2927 checkFn("previousSibling", part
, doneName
, checkSet
, nodeCheck
, isXML
);
2931 ID: function(match
, context
, isXML
){
2932 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
2933 var m
= context
.getElementById(match
[1]);
2934 return m
? [m
] : [];
2937 NAME: function(match
, context
){
2938 if ( typeof context
.getElementsByName
!== "undefined" ) {
2939 var ret
= [], results
= context
.getElementsByName(match
[1]);
2941 for ( var i
= 0, l
= results
.length
; i
< l
; i
++ ) {
2942 if ( results
[i
].getAttribute("name") === match
[1] ) {
2943 ret
.push( results
[i
] );
2947 return ret
.length
=== 0 ? null : ret
;
2950 TAG: function(match
, context
){
2951 return context
.getElementsByTagName(match
[1]);
2955 CLASS: function(match
, curLoop
, inplace
, result
, not
, isXML
){
2956 match
= " " + match
[1].replace(/\\/g
, "") + " ";
2962 for ( var i
= 0, elem
; (elem
= curLoop
[i
]) != null; i
++ ) {
2964 if ( not
^ (elem
.className
&& (" " + elem
.className
+ " ").replace(/[\t\n]/g, " ").indexOf(match
) >= 0) ) {
2966 result
.push( elem
);
2968 } else if ( inplace
) {
2976 ID: function(match
){
2977 return match
[1].replace(/\\/g
, "");
2979 TAG: function(match
, curLoop
){
2980 return match
[1].toLowerCase();
2982 CHILD: function(match
){
2983 if ( match
[1] === "nth" ) {
2984 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
2985 var test
= /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
2986 match
[2] === "even" && "2n" || match
[2] === "odd" && "2n+1" ||
2987 !/\D/.test( match
[2] ) && "0n+" + match
[2] || match
[2]);
2989 // calculate the numbers (first)n+(last) including if they are negative
2990 match
[2] = (test
[1] + (test
[2] || 1)) - 0;
2991 match
[3] = test
[3] - 0;
2994 // TODO: Move to normal caching system
2999 ATTR: function(match
, curLoop
, inplace
, result
, not
, isXML
){
3000 var name
= match
[1].replace(/\\/g
, "");
3002 if ( !isXML
&& Expr
.attrMap
[name
] ) {
3003 match
[1] = Expr
.attrMap
[name
];
3006 if ( match
[2] === "~=" ) {
3007 match
[4] = " " + match
[4] + " ";
3012 PSEUDO: function(match
, curLoop
, inplace
, result
, not
){
3013 if ( match
[1] === "not" ) {
3014 // If we're dealing with a complex expression, or a simple one
3015 if ( ( chunker
.exec(match
[3]) || "" ).length
> 1 || /^\w/.test(match
[3]) ) {
3016 match
[3] = Sizzle(match
[3], null, null, curLoop
);
3018 var ret
= Sizzle
.filter(match
[3], curLoop
, inplace
, true ^ not
);
3020 result
.push
.apply( result
, ret
);
3024 } else if ( Expr
.match
.POS
.test( match
[0] ) || Expr
.match
.CHILD
.test( match
[0] ) ) {
3030 POS: function(match
){
3031 match
.unshift( true );
3036 enabled: function(elem
){
3037 return elem
.disabled
=== false && elem
.type
!== "hidden";
3039 disabled: function(elem
){
3040 return elem
.disabled
=== true;
3042 checked: function(elem
){
3043 return elem
.checked
=== true;
3045 selected: function(elem
){
3046 // Accessing this property makes selected-by-default
3047 // options in Safari work properly
3048 elem
.parentNode
.selectedIndex
;
3049 return elem
.selected
=== true;
3051 parent: function(elem
){
3052 return !!elem
.firstChild
;
3054 empty: function(elem
){
3055 return !elem
.firstChild
;
3057 has: function(elem
, i
, match
){
3058 return !!Sizzle( match
[3], elem
).length
;
3060 header: function(elem
){
3061 return /h\d/i.test( elem
.nodeName
);
3063 text: function(elem
){
3064 return "text" === elem
.type
;
3066 radio: function(elem
){
3067 return "radio" === elem
.type
;
3069 checkbox: function(elem
){
3070 return "checkbox" === elem
.type
;
3072 file: function(elem
){
3073 return "file" === elem
.type
;
3075 password: function(elem
){
3076 return "password" === elem
.type
;
3078 submit: function(elem
){
3079 return "submit" === elem
.type
;
3081 image: function(elem
){
3082 return "image" === elem
.type
;
3084 reset: function(elem
){
3085 return "reset" === elem
.type
;
3087 button: function(elem
){
3088 return "button" === elem
.type
|| elem
.nodeName
.toLowerCase() === "button";
3090 input: function(elem
){
3091 return /input|select|textarea|button/i.test(elem
.nodeName
);
3095 first: function(elem
, i
){
3098 last: function(elem
, i
, match
, array
){
3099 return i
=== array
.length
- 1;
3101 even: function(elem
, i
){
3104 odd: function(elem
, i
){
3107 lt: function(elem
, i
, match
){
3108 return i
< match
[3] - 0;
3110 gt: function(elem
, i
, match
){
3111 return i
> match
[3] - 0;
3113 nth: function(elem
, i
, match
){
3114 return match
[3] - 0 === i
;
3116 eq: function(elem
, i
, match
){
3117 return match
[3] - 0 === i
;
3121 PSEUDO: function(elem
, match
, i
, array
){
3122 var name
= match
[1], filter
= Expr
.filters
[ name
];
3125 return filter( elem
, i
, match
, array
);
3126 } else if ( name
=== "contains" ) {
3127 return (elem
.textContent
|| elem
.innerText
|| getText([ elem
]) || "").indexOf(match
[3]) >= 0;
3128 } else if ( name
=== "not" ) {
3131 for ( var i
= 0, l
= not
.length
; i
< l
; i
++ ) {
3132 if ( not
[i
] === elem
) {
3139 Sizzle
.error( "Syntax error, unrecognized expression: " + name
);
3142 CHILD: function(elem
, match
){
3143 var type
= match
[1], node
= elem
;
3147 while ( (node
= node
.previousSibling
) ) {
3148 if ( node
.nodeType
=== 1 ) {
3152 if ( type
=== "first" ) {
3157 while ( (node
= node
.nextSibling
) ) {
3158 if ( node
.nodeType
=== 1 ) {
3164 var first
= match
[2], last
= match
[3];
3166 if ( first
=== 1 && last
=== 0 ) {
3170 var doneName
= match
[0],
3171 parent
= elem
.parentNode
;
3173 if ( parent
&& (parent
.sizcache
!== doneName
|| !elem
.nodeIndex
) ) {
3175 for ( node
= parent
.firstChild
; node
; node
= node
.nextSibling
) {
3176 if ( node
.nodeType
=== 1 ) {
3177 node
.nodeIndex
= ++count
;
3180 parent
.sizcache
= doneName
;
3183 var diff
= elem
.nodeIndex
- last
;
3184 if ( first
=== 0 ) {
3187 return ( diff
% first
=== 0 && diff
/ first
>= 0 );
3191 ID: function(elem
, match
){
3192 return elem
.nodeType
=== 1 && elem
.getAttribute("id") === match
;
3194 TAG: function(elem
, match
){
3195 return (match
=== "*" && elem
.nodeType
=== 1) || elem
.nodeName
.toLowerCase() === match
;
3197 CLASS: function(elem
, match
){
3198 return (" " + (elem
.className
|| elem
.getAttribute("class")) + " ")
3199 .indexOf( match
) > -1;
3201 ATTR: function(elem
, match
){
3202 var name
= match
[1],
3203 result
= Expr
.attrHandle
[ name
] ?
3204 Expr
.attrHandle
[ name
]( elem
) :
3205 elem
[ name
] != null ?
3207 elem
.getAttribute( name
),
3208 value
= result
+ "",
3212 return result
== null ?
3217 value
.indexOf(check
) >= 0 :
3219 (" " + value
+ " ").indexOf(check
) >= 0 :
3221 value
&& result
!== false :
3225 value
.indexOf(check
) === 0 :
3227 value
.substr(value
.length
- check
.length
) === check
:
3229 value
=== check
|| value
.substr(0, check
.length
+ 1) === check
+ "-" :
3232 POS: function(elem
, match
, i
, array
){
3233 var name
= match
[2], filter
= Expr
.setFilters
[ name
];
3236 return filter( elem
, i
, match
, array
);
3242 var origPOS
= Expr
.match
.POS
;
3244 for ( var type
in Expr
.match
) {
3245 Expr
.match
[ type
] = new RegExp( Expr
.match
[ type
].source
+ /(?![^\[]*\])(?![^\(]*\))/.source
);
3246 Expr
.leftMatch
[ type
] = new RegExp( /(^(?:.|\r|\n)*?)/.source
+ Expr
.match
[ type
].source
.replace(/\\(\d+)/g, function(all
, num
){
3247 return "\\" + (num
- 0 + 1);
3251 var makeArray = function(array
, results
) {
3252 array
= Array
.prototype.slice
.call( array
, 0 );
3255 results
.push
.apply( results
, array
);
3262 // Perform a simple check to determine if the browser is capable of
3263 // converting a NodeList to an array using builtin methods.
3265 Array
.prototype.slice
.call( document
.documentElement
.childNodes
, 0 );
3267 // Provide a fallback method if it does not work
3269 makeArray = function(array
, results
) {
3270 var ret
= results
|| [];
3272 if ( toString
.call(array
) === "[object Array]" ) {
3273 Array
.prototype.push
.apply( ret
, array
);
3275 if ( typeof array
.length
=== "number" ) {
3276 for ( var i
= 0, l
= array
.length
; i
< l
; i
++ ) {
3277 ret
.push( array
[i
] );
3280 for ( var i
= 0; array
[i
]; i
++ ) {
3281 ret
.push( array
[i
] );
3292 if ( document
.documentElement
.compareDocumentPosition
) {
3293 sortOrder = function( a
, b
) {
3294 if ( !a
.compareDocumentPosition
|| !b
.compareDocumentPosition
) {
3296 hasDuplicate
= true;
3298 return a
.compareDocumentPosition
? -1 : 1;
3301 var ret
= a
.compareDocumentPosition(b
) & 4 ? -1 : a
=== b
? 0 : 1;
3303 hasDuplicate
= true;
3307 } else if ( "sourceIndex" in document
.documentElement
) {
3308 sortOrder = function( a
, b
) {
3309 if ( !a
.sourceIndex
|| !b
.sourceIndex
) {
3311 hasDuplicate
= true;
3313 return a
.sourceIndex
? -1 : 1;
3316 var ret
= a
.sourceIndex
- b
.sourceIndex
;
3318 hasDuplicate
= true;
3322 } else if ( document
.createRange
) {
3323 sortOrder = function( a
, b
) {
3324 if ( !a
.ownerDocument
|| !b
.ownerDocument
) {
3326 hasDuplicate
= true;
3328 return a
.ownerDocument
? -1 : 1;
3331 var aRange
= a
.ownerDocument
.createRange(), bRange
= b
.ownerDocument
.createRange();
3332 aRange
.setStart(a
, 0);
3333 aRange
.setEnd(a
, 0);
3334 bRange
.setStart(b
, 0);
3335 bRange
.setEnd(b
, 0);
3336 var ret
= aRange
.compareBoundaryPoints(Range
.START_TO_END
, bRange
);
3338 hasDuplicate
= true;
3344 // Utility function for retreiving the text value of an array of DOM nodes
3345 function getText( elems
) {
3348 for ( var i
= 0; elems
[i
]; i
++ ) {
3351 // Get the text from text nodes and CDATA nodes
3352 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 4 ) {
3353 ret
+= elem
.nodeValue
;
3355 // Traverse everything else, except comment nodes
3356 } else if ( elem
.nodeType
!== 8 ) {
3357 ret
+= getText( elem
.childNodes
);
3364 // Check to see if the browser returns elements by name when
3365 // querying by getElementById (and provide a workaround)
3367 // We're going to inject a fake input element with a specified name
3368 var form
= document
.createElement("div"),
3369 id
= "script" + (new Date
).getTime();
3370 form
.innerHTML
= "<a name='" + id
+ "'/>";
3372 // Inject it into the root element, check its status, and remove it quickly
3373 var root
= document
.documentElement
;
3374 root
.insertBefore( form
, root
.firstChild
);
3376 // The workaround has to do additional checks after a getElementById
3377 // Which slows things down for other browsers (hence the branching)
3378 if ( document
.getElementById( id
) ) {
3379 Expr
.find
.ID = function(match
, context
, isXML
){
3380 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
3381 var m
= context
.getElementById(match
[1]);
3382 return m
? m
.id
=== match
[1] || typeof m
.getAttributeNode
!== "undefined" && m
.getAttributeNode("id").nodeValue
=== match
[1] ? [m
] : undefined : [];
3386 Expr
.filter
.ID = function(elem
, match
){
3387 var node
= typeof elem
.getAttributeNode
!== "undefined" && elem
.getAttributeNode("id");
3388 return elem
.nodeType
=== 1 && node
&& node
.nodeValue
=== match
;
3392 root
.removeChild( form
);
3393 root
= form
= null; // release memory in IE
3397 // Check to see if the browser returns only elements
3398 // when doing getElementsByTagName("*")
3400 // Create a fake element
3401 var div
= document
.createElement("div");
3402 div
.appendChild( document
.createComment("") );
3404 // Make sure no comments are found
3405 if ( div
.getElementsByTagName("*").length
> 0 ) {
3406 Expr
.find
.TAG = function(match
, context
){
3407 var results
= context
.getElementsByTagName(match
[1]);
3409 // Filter out possible comments
3410 if ( match
[1] === "*" ) {
3413 for ( var i
= 0; results
[i
]; i
++ ) {
3414 if ( results
[i
].nodeType
=== 1 ) {
3415 tmp
.push( results
[i
] );
3426 // Check to see if an attribute returns normalized href attributes
3427 div
.innerHTML
= "<a href='#'></a>";
3428 if ( div
.firstChild
&& typeof div
.firstChild
.getAttribute
!== "undefined" &&
3429 div
.firstChild
.getAttribute("href") !== "#" ) {
3430 Expr
.attrHandle
.href = function(elem
){
3431 return elem
.getAttribute("href", 2);
3435 div
= null; // release memory in IE
3438 if ( document
.querySelectorAll
) {
3440 var oldSizzle
= Sizzle
, div
= document
.createElement("div");
3441 div
.innerHTML
= "<p class='TEST'></p>";
3443 // Safari can't handle uppercase or unicode characters when
3445 if ( div
.querySelectorAll
&& div
.querySelectorAll(".TEST").length
=== 0 ) {
3449 Sizzle = function(query
, context
, extra
, seed
){
3450 context
= context
|| document
;
3452 // Only use querySelectorAll on non-XML documents
3453 // (ID selectors don't work in non-HTML documents)
3454 if ( !seed
&& context
.nodeType
=== 9 && !isXML(context
) ) {
3456 return makeArray( context
.querySelectorAll(query
), extra
);
3460 return oldSizzle(query
, context
, extra
, seed
);
3463 for ( var prop
in oldSizzle
) {
3464 Sizzle
[ prop
] = oldSizzle
[ prop
];
3467 div
= null; // release memory in IE
3472 var div
= document
.createElement("div");
3474 div
.innerHTML
= "<div class='test e'></div><div class='test'></div>";
3476 // Opera can't find a second classname (in 9.6)
3477 // Also, make sure that getElementsByClassName actually exists
3478 if ( !div
.getElementsByClassName
|| div
.getElementsByClassName("e").length
=== 0 ) {
3482 // Safari caches class attributes, doesn't catch changes (in 3.2)
3483 div
.lastChild
.className
= "e";
3485 if ( div
.getElementsByClassName("e").length
=== 1 ) {
3489 Expr
.order
.splice(1, 0, "CLASS");
3490 Expr
.find
.CLASS = function(match
, context
, isXML
) {
3491 if ( typeof context
.getElementsByClassName
!== "undefined" && !isXML
) {
3492 return context
.getElementsByClassName(match
[1]);
3496 div
= null; // release memory in IE
3499 function dirNodeCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
3500 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
3501 var elem
= checkSet
[i
];
3507 if ( elem
.sizcache
=== doneName
) {
3508 match
= checkSet
[elem
.sizset
];
3512 if ( elem
.nodeType
=== 1 && !isXML
){
3513 elem
.sizcache
= doneName
;
3517 if ( elem
.nodeName
.toLowerCase() === cur
) {
3525 checkSet
[i
] = match
;
3530 function dirCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
3531 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
3532 var elem
= checkSet
[i
];
3538 if ( elem
.sizcache
=== doneName
) {
3539 match
= checkSet
[elem
.sizset
];
3543 if ( elem
.nodeType
=== 1 ) {
3545 elem
.sizcache
= doneName
;
3548 if ( typeof cur
!== "string" ) {
3549 if ( elem
=== cur
) {
3554 } else if ( Sizzle
.filter( cur
, [elem
] ).length
> 0 ) {
3563 checkSet
[i
] = match
;
3568 var contains
= document
.compareDocumentPosition
? function(a
, b
){
3569 return a
.compareDocumentPosition(b
) & 16;
3571 return a
!== b
&& (a
.contains
? a
.contains(b
) : true);
3574 var isXML = function(elem
){
3575 // documentElement is verified for cases where it doesn't yet exist
3576 // (such as loading iframes in IE - #4833)
3577 var documentElement
= (elem
? elem
.ownerDocument
|| elem
: 0).documentElement
;
3578 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
3581 var posProcess = function(selector
, context
){
3582 var tmpSet
= [], later
= "", match
,
3583 root
= context
.nodeType
? [context
] : context
;
3585 // Position selectors must be done after the filter
3586 // And so must :not(positional) so we move all PSEUDOs to the end
3587 while ( (match
= Expr
.match
.PSEUDO
.exec( selector
)) ) {
3589 selector
= selector
.replace( Expr
.match
.PSEUDO
, "" );
3592 selector
= Expr
.relative
[selector
] ? selector
+ "*" : selector
;
3594 for ( var i
= 0, l
= root
.length
; i
< l
; i
++ ) {
3595 Sizzle( selector
, root
[i
], tmpSet
);
3598 return Sizzle
.filter( later
, tmpSet
);
3602 jQuery
.find
= Sizzle
;
3603 jQuery
.expr
= Sizzle
.selectors
;
3604 jQuery
.expr
[":"] = jQuery
.expr
.filters
;
3605 jQuery
.unique
= Sizzle
.uniqueSort
;
3606 jQuery
.getText
= getText
;
3607 jQuery
.isXMLDoc
= isXML
;
3608 jQuery
.contains
= contains
;
3612 window
.Sizzle
= Sizzle
;
3615 var runtil
= /Until$/,
3616 rparentsprev
= /^(?:parents|prevUntil|prevAll)/,
3617 // Note: This RegExp should be improved, or likely pulled from Sizzle
3618 rmultiselector
= /,/,
3619 slice
= Array
.prototype.slice
;
3621 // Implement the identical functionality for filter and not
3622 var winnow = function( elements
, qualifier
, keep
) {
3623 if ( jQuery
.isFunction( qualifier
) ) {
3624 return jQuery
.grep(elements
, function( elem
, i
) {
3625 return !!qualifier
.call( elem
, i
, elem
) === keep
;
3628 } else if ( qualifier
.nodeType
) {
3629 return jQuery
.grep(elements
, function( elem
, i
) {
3630 return (elem
=== qualifier
) === keep
;
3633 } else if ( typeof qualifier
=== "string" ) {
3634 var filtered
= jQuery
.grep(elements
, function( elem
) {
3635 return elem
.nodeType
=== 1;
3638 if ( isSimple
.test( qualifier
) ) {
3639 return jQuery
.filter(qualifier
, filtered
, !keep
);
3641 qualifier
= jQuery
.filter( qualifier
, filtered
);
3645 return jQuery
.grep(elements
, function( elem
, i
) {
3646 return (jQuery
.inArray( elem
, qualifier
) >= 0) === keep
;
3651 find: function( selector
) {
3652 var ret
= this.pushStack( "", "find", selector
), length
= 0;
3654 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
3655 length
= ret
.length
;
3656 jQuery
.find( selector
, this[i
], ret
);
3659 // Make sure that the results are unique
3660 for ( var n
= length
; n
< ret
.length
; n
++ ) {
3661 for ( var r
= 0; r
< length
; r
++ ) {
3662 if ( ret
[r
] === ret
[n
] ) {
3674 has: function( target
) {
3675 var targets
= jQuery( target
);
3676 return this.filter(function() {
3677 for ( var i
= 0, l
= targets
.length
; i
< l
; i
++ ) {
3678 if ( jQuery
.contains( this, targets
[i
] ) ) {
3685 not: function( selector
) {
3686 return this.pushStack( winnow(this, selector
, false), "not", selector
);
3689 filter: function( selector
) {
3690 return this.pushStack( winnow(this, selector
, true), "filter", selector
);
3693 is: function( selector
) {
3694 return !!selector
&& jQuery
.filter( selector
, this ).length
> 0;
3697 closest: function( selectors
, context
) {
3698 if ( jQuery
.isArray( selectors
) ) {
3699 var ret
= [], cur
= this[0], match
, matches
= {}, selector
;
3701 if ( cur
&& selectors
.length
) {
3702 for ( var i
= 0, l
= selectors
.length
; i
< l
; i
++ ) {
3703 selector
= selectors
[i
];
3705 if ( !matches
[selector
] ) {
3706 matches
[selector
] = jQuery
.expr
.match
.POS
.test( selector
) ?
3707 jQuery( selector
, context
|| this.context
) :
3712 while ( cur
&& cur
.ownerDocument
&& cur
!== context
) {
3713 for ( selector
in matches
) {
3714 match
= matches
[selector
];
3716 if ( match
.jquery
? match
.index(cur
) > -1 : jQuery(cur
).is(match
) ) {
3717 ret
.push({ selector
: selector
, elem
: cur
});
3718 delete matches
[selector
];
3721 cur
= cur
.parentNode
;
3728 var pos
= jQuery
.expr
.match
.POS
.test( selectors
) ?
3729 jQuery( selectors
, context
|| this.context
) : null;
3731 return this.map(function( i
, cur
) {
3732 while ( cur
&& cur
.ownerDocument
&& cur
!== context
) {
3733 if ( pos
? pos
.index(cur
) > -1 : jQuery(cur
).is(selectors
) ) {
3736 cur
= cur
.parentNode
;
3742 // Determine the position of an element within
3743 // the matched set of elements
3744 index: function( elem
) {
3745 if ( !elem
|| typeof elem
=== "string" ) {
3746 return jQuery
.inArray( this[0],
3747 // If it receives a string, the selector is used
3748 // If it receives nothing, the siblings are used
3749 elem
? jQuery( elem
) : this.parent().children() );
3751 // Locate the position of the desired element
3752 return jQuery
.inArray(
3753 // If it receives a jQuery object, the first element is used
3754 elem
.jquery
? elem
[0] : elem
, this );
3757 add: function( selector
, context
) {
3758 var set = typeof selector
=== "string" ?
3759 jQuery( selector
, context
|| this.context
) :
3760 jQuery
.makeArray( selector
),
3761 all
= jQuery
.merge( this.get(), set );
3763 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all
[0] ) ?
3765 jQuery
.unique( all
) );
3768 andSelf: function() {
3769 return this.add( this.prevObject
);
3773 // A painfully simple check to see if an element is disconnected
3774 // from a document (should be improved, where feasible).
3775 function isDisconnected( node
) {
3776 return !node
|| !node
.parentNode
|| node
.parentNode
.nodeType
=== 11;
3780 parent: function( elem
) {
3781 var parent
= elem
.parentNode
;
3782 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
3784 parents: function( elem
) {
3785 return jQuery
.dir( elem
, "parentNode" );
3787 parentsUntil: function( elem
, i
, until
) {
3788 return jQuery
.dir( elem
, "parentNode", until
);
3790 next: function( elem
) {
3791 return jQuery
.nth( elem
, 2, "nextSibling" );
3793 prev: function( elem
) {
3794 return jQuery
.nth( elem
, 2, "previousSibling" );
3796 nextAll: function( elem
) {
3797 return jQuery
.dir( elem
, "nextSibling" );
3799 prevAll: function( elem
) {
3800 return jQuery
.dir( elem
, "previousSibling" );
3802 nextUntil: function( elem
, i
, until
) {
3803 return jQuery
.dir( elem
, "nextSibling", until
);
3805 prevUntil: function( elem
, i
, until
) {
3806 return jQuery
.dir( elem
, "previousSibling", until
);
3808 siblings: function( elem
) {
3809 return jQuery
.sibling( elem
.parentNode
.firstChild
, elem
);
3811 children: function( elem
) {
3812 return jQuery
.sibling( elem
.firstChild
);
3814 contents: function( elem
) {
3815 return jQuery
.nodeName( elem
, "iframe" ) ?
3816 elem
.contentDocument
|| elem
.contentWindow
.document
:
3817 jQuery
.makeArray( elem
.childNodes
);
3819 }, function( name
, fn
) {
3820 jQuery
.fn
[ name
] = function( until
, selector
) {
3821 var ret
= jQuery
.map( this, fn
, until
);
3823 if ( !runtil
.test( name
) ) {
3827 if ( selector
&& typeof selector
=== "string" ) {
3828 ret
= jQuery
.filter( selector
, ret
);
3831 ret
= this.length
> 1 ? jQuery
.unique( ret
) : ret
;
3833 if ( (this.length
> 1 || rmultiselector
.test( selector
)) && rparentsprev
.test( name
) ) {
3834 ret
= ret
.reverse();
3837 return this.pushStack( ret
, name
, slice
.call(arguments
).join(",") );
3842 filter: function( expr
, elems
, not
) {
3844 expr
= ":not(" + expr
+ ")";
3847 return jQuery
.find
.matches(expr
, elems
);
3850 dir: function( elem
, dir
, until
) {
3851 var matched
= [], cur
= elem
[dir
];
3852 while ( cur
&& cur
.nodeType
!== 9 && (until
=== undefined || cur
.nodeType
!== 1 || !jQuery( cur
).is( until
)) ) {
3853 if ( cur
.nodeType
=== 1 ) {
3854 matched
.push( cur
);
3861 nth: function( cur
, result
, dir
, elem
) {
3862 result
= result
|| 1;
3865 for ( ; cur
; cur
= cur
[dir
] ) {
3866 if ( cur
.nodeType
=== 1 && ++num
=== result
) {
3874 sibling: function( n
, elem
) {
3877 for ( ; n
; n
= n
.nextSibling
) {
3878 if ( n
.nodeType
=== 1 && n
!== elem
) {
3886 var rinlinejQuery
= / jQuery
\d
+="(?:\d+|null)"/g
,
3887 rleadingWhitespace
= /^\s+/,
3888 rxhtmlTag
= /(<([\w:]+)[^>]*?)\/>/g,
3889 rselfClosing
= /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
3890 rtagName
= /<([\w:]+)/,
3893 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
3894 fcloseTag = function( all
, front
, tag
) {
3895 return rselfClosing
.test( tag
) ?
3897 front
+ "></" + tag
+ ">";
3900 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
3901 legend
: [ 1, "<fieldset>", "</fieldset>" ],
3902 thead
: [ 1, "<table>", "</table>" ],
3903 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
3904 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
3905 col
: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
3906 area
: [ 1, "<map>", "</map>" ],
3907 _default
: [ 0, "", "" ]
3910 wrapMap
.optgroup
= wrapMap
.option
;
3911 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
3912 wrapMap
.th
= wrapMap
.td
;
3914 // IE can't serialize <link> and <script> tags normally
3915 if ( !jQuery
.support
.htmlSerialize
) {
3916 wrapMap
._default
= [ 1, "div<div>", "</div>" ];
3920 text: function( text
) {
3921 if ( jQuery
.isFunction(text
) ) {
3922 return this.each(function(i
) {
3923 var self
= jQuery(this);
3924 self
.text( text
.call(this, i
, self
.text()) );
3928 if ( typeof text
!== "object" && text
!== undefined ) {
3929 return this.empty().append( (this[0] && this[0].ownerDocument
|| document
).createTextNode( text
) );
3932 return jQuery
.getText( this );
3935 wrapAll: function( html
) {
3936 if ( jQuery
.isFunction( html
) ) {
3937 return this.each(function(i
) {
3938 jQuery(this).wrapAll( html
.call(this, i
) );
3943 // The elements to wrap the target around
3944 var wrap
= jQuery( html
, this[0].ownerDocument
).eq(0).clone(true);
3946 if ( this[0].parentNode
) {
3947 wrap
.insertBefore( this[0] );
3950 wrap
.map(function() {
3953 while ( elem
.firstChild
&& elem
.firstChild
.nodeType
=== 1 ) {
3954 elem
= elem
.firstChild
;
3964 wrapInner: function( html
) {
3965 if ( jQuery
.isFunction( html
) ) {
3966 return this.each(function(i
) {
3967 jQuery(this).wrapInner( html
.call(this, i
) );
3971 return this.each(function() {
3972 var self
= jQuery( this ), contents
= self
.contents();
3974 if ( contents
.length
) {
3975 contents
.wrapAll( html
);
3978 self
.append( html
);
3983 wrap: function( html
) {
3984 return this.each(function() {
3985 jQuery( this ).wrapAll( html
);
3989 unwrap: function() {
3990 return this.parent().each(function() {
3991 if ( !jQuery
.nodeName( this, "body" ) ) {
3992 jQuery( this ).replaceWith( this.childNodes
);
3997 append: function() {
3998 return this.domManip(arguments
, true, function( elem
) {
3999 if ( this.nodeType
=== 1 ) {
4000 this.appendChild( elem
);
4005 prepend: function() {
4006 return this.domManip(arguments
, true, function( elem
) {
4007 if ( this.nodeType
=== 1 ) {
4008 this.insertBefore( elem
, this.firstChild
);
4013 before: function() {
4014 if ( this[0] && this[0].parentNode
) {
4015 return this.domManip(arguments
, false, function( elem
) {
4016 this.parentNode
.insertBefore( elem
, this );
4018 } else if ( arguments
.length
) {
4019 var set = jQuery(arguments
[0]);
4020 set.push
.apply( set, this.toArray() );
4021 return this.pushStack( set, "before", arguments
);
4026 if ( this[0] && this[0].parentNode
) {
4027 return this.domManip(arguments
, false, function( elem
) {
4028 this.parentNode
.insertBefore( elem
, this.nextSibling
);
4030 } else if ( arguments
.length
) {
4031 var set = this.pushStack( this, "after", arguments
);
4032 set.push
.apply( set, jQuery(arguments
[0]).toArray() );
4037 clone: function( events
) {
4039 var ret
= this.map(function() {
4040 if ( !jQuery
.support
.noCloneEvent
&& !jQuery
.isXMLDoc(this) ) {
4041 // IE copies events bound via attachEvent when
4042 // using cloneNode. Calling detachEvent on the
4043 // clone will also remove the events from the orignal
4044 // In order to get around this, we use innerHTML.
4045 // Unfortunately, this means some modifications to
4046 // attributes in IE that are actually only stored
4047 // as properties will not be copied (such as the
4048 // the name attribute on an input).
4049 var html
= this.outerHTML
, ownerDocument
= this.ownerDocument
;
4051 var div
= ownerDocument
.createElement("div");
4052 div
.appendChild( this.cloneNode(true) );
4053 html
= div
.innerHTML
;
4056 return jQuery
.clean([html
.replace(rinlinejQuery
, "")
4057 .replace(rleadingWhitespace
, "")], ownerDocument
)[0];
4059 return this.cloneNode(true);
4063 // Copy the events from the original to the clone
4064 if ( events
=== true ) {
4065 cloneCopyEvent( this, ret
);
4066 cloneCopyEvent( this.find("*"), ret
.find("*") );
4069 // Return the cloned set
4073 html: function( value
) {
4074 if ( value
=== undefined ) {
4075 return this[0] && this[0].nodeType
=== 1 ?
4076 this[0].innerHTML
.replace(rinlinejQuery
, "") :
4079 // See if we can take a shortcut and just use innerHTML
4080 } else if ( typeof value
=== "string" && !/<script/i.test( value
) &&
4081 (jQuery
.support
.leadingWhitespace
|| !rleadingWhitespace
.test( value
)) &&
4082 !wrapMap
[ (rtagName
.exec( value
) || ["", ""])[1].toLowerCase() ] ) {
4084 value
= value
.replace(rxhtmlTag
, fcloseTag
);
4087 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
4088 // Remove element nodes and prevent memory leaks
4089 if ( this[i
].nodeType
=== 1 ) {
4090 jQuery
.cleanData( this[i
].getElementsByTagName("*") );
4091 this[i
].innerHTML
= value
;
4095 // If using innerHTML throws an exception, use the fallback method
4097 this.empty().append( value
);
4100 } else if ( jQuery
.isFunction( value
) ) {
4101 this.each(function(i
){
4102 var self
= jQuery(this), old
= self
.html();
4103 self
.empty().append(function(){
4104 return value
.call( this, i
, old
);
4109 this.empty().append( value
);
4115 replaceWith: function( value
) {
4116 if ( this[0] && this[0].parentNode
) {
4117 // Make sure that the elements are removed from the DOM before they are inserted
4118 // this can help fix replacing a parent with child elements
4119 if ( !jQuery
.isFunction( value
) ) {
4120 value
= jQuery( value
).detach();
4123 return this.each(function(i
) {
4124 var self
= jQuery(this), old
= self
.html();
4125 self
.replaceWith( value
.call( this, i
, old
) );
4129 return this.each(function() {
4130 var next
= this.nextSibling
, parent
= this.parentNode
;
4132 jQuery(this).remove();
4135 jQuery(next
).before( value
);
4137 jQuery(parent
).append( value
);
4141 return this.pushStack( jQuery(jQuery
.isFunction(value
) ? value() : value
), "replaceWith", value
);
4145 detach: function( selector
) {
4146 return this.remove( selector
, true );
4149 domManip: function( args
, table
, callback
) {
4150 var results
, first
, value
= args
[0], scripts
= [];
4152 // We can't cloneNode fragments that contain checked, in WebKit
4153 if ( !jQuery
.support
.checkClone
&& arguments
.length
=== 3 && typeof value
=== "string" && rchecked
.test( value
) ) {
4154 return this.each(function() {
4155 jQuery(this).domManip( args
, table
, callback
, true );
4159 if ( jQuery
.isFunction(value
) ) {
4160 return this.each(function(i
) {
4161 var self
= jQuery(this);
4162 args
[0] = value
.call(this, i
, table
? self
.html() : undefined);
4163 self
.domManip( args
, table
, callback
);
4168 // If we're in a fragment, just use that instead of building a new one
4169 if ( args
[0] && args
[0].parentNode
&& args
[0].parentNode
.nodeType
=== 11 ) {
4170 results
= { fragment
: args
[0].parentNode
};
4172 results
= buildFragment( args
, this, scripts
);
4175 first
= results
.fragment
.firstChild
;
4178 table
= table
&& jQuery
.nodeName( first
, "tr" );
4180 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
4183 root(this[i
], first
) :
4185 results
.cacheable
|| this.length
> 1 || i
> 0 ?
4186 results
.fragment
.cloneNode(true) :
4193 jQuery
.each( scripts
, evalScript
);
4199 function root( elem
, cur
) {
4200 return jQuery
.nodeName(elem
, "table") ?
4201 (elem
.getElementsByTagName("tbody")[0] ||
4202 elem
.appendChild(elem
.ownerDocument
.createElement("tbody"))) :
4208 function cloneCopyEvent(orig
, ret
) {
4211 ret
.each(function() {
4212 if ( this.nodeName
!== (orig
[i
] && orig
[i
].nodeName
) ) {
4216 var oldData
= jQuery
.data( orig
[i
++] ), curData
= jQuery
.data( this, oldData
), events
= oldData
&& oldData
.events
;
4219 delete curData
.handle
;
4220 curData
.events
= {};
4222 for ( var type
in events
) {
4223 for ( var handler
in events
[ type
] ) {
4224 jQuery
.event
.add( this, type
, events
[ type
][ handler
], events
[ type
][ handler
].data
);
4231 function buildFragment( args
, nodes
, scripts
) {
4232 var fragment
, cacheable
, cacheresults
, doc
;
4234 // webkit does not clone 'checked' attribute of radio inputs on cloneNode, so don't cache if string has a checked
4235 if ( args
.length
=== 1 && typeof args
[0] === "string" && args
[0].length
< 512 && args
[0].indexOf("<option") < 0 && (jQuery
.support
.checkClone
|| !rchecked
.test( args
[0] )) ) {
4237 cacheresults
= jQuery
.fragments
[ args
[0] ];
4238 if ( cacheresults
) {
4239 if ( cacheresults
!== 1 ) {
4240 fragment
= cacheresults
;
4246 doc
= (nodes
&& nodes
[0] ? nodes
[0].ownerDocument
|| nodes
[0] : document
);
4247 fragment
= doc
.createDocumentFragment();
4248 jQuery
.clean( args
, doc
, fragment
, scripts
);
4252 jQuery
.fragments
[ args
[0] ] = cacheresults
? fragment
: 1;
4255 return { fragment
: fragment
, cacheable
: cacheable
};
4258 jQuery
.fragments
= {};
4262 prependTo
: "prepend",
4263 insertBefore
: "before",
4264 insertAfter
: "after",
4265 replaceAll
: "replaceWith"
4266 }, function( name
, original
) {
4267 jQuery
.fn
[ name
] = function( selector
) {
4268 var ret
= [], insert
= jQuery( selector
);
4270 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
4271 var elems
= (i
> 0 ? this.clone(true) : this).get();
4272 jQuery
.fn
[ original
].apply( jQuery(insert
[i
]), elems
);
4273 ret
= ret
.concat( elems
);
4275 return this.pushStack( ret
, name
, insert
.selector
);
4280 // keepData is for internal use only--do not document
4281 remove: function( selector
, keepData
) {
4282 if ( !selector
|| jQuery
.filter( selector
, [ this ] ).length
) {
4283 if ( !keepData
&& this.nodeType
=== 1 ) {
4284 jQuery
.cleanData( this.getElementsByTagName("*") );
4285 jQuery
.cleanData( [ this ] );
4288 if ( this.parentNode
) {
4289 this.parentNode
.removeChild( this );
4295 // Remove element nodes and prevent memory leaks
4296 if ( this.nodeType
=== 1 ) {
4297 jQuery
.cleanData( this.getElementsByTagName("*") );
4300 // Remove any remaining nodes
4301 while ( this.firstChild
) {
4302 this.removeChild( this.firstChild
);
4305 }, function( name
, fn
) {
4306 jQuery
.fn
[ name
] = function() {
4307 return this.each( fn
, arguments
);
4312 clean: function( elems
, context
, fragment
, scripts
) {
4313 context
= context
|| document
;
4315 // !context.createElement fails in IE with an error but returns typeof 'object'
4316 if ( typeof context
.createElement
=== "undefined" ) {
4317 context
= context
.ownerDocument
|| context
[0] && context
[0].ownerDocument
|| document
;
4322 jQuery
.each(elems
, function( i
, elem
) {
4323 if ( typeof elem
=== "number" ) {
4331 // Convert html string into DOM nodes
4332 if ( typeof elem
=== "string" && !rhtml
.test( elem
) ) {
4333 elem
= context
.createTextNode( elem
);
4335 } else if ( typeof elem
=== "string" ) {
4336 // Fix "XHTML"-style tags in all browsers
4337 elem
= elem
.replace(rxhtmlTag
, fcloseTag
);
4339 // Trim whitespace, otherwise indexOf won't work as expected
4340 var tag
= (rtagName
.exec( elem
) || ["", ""])[1].toLowerCase(),
4341 wrap
= wrapMap
[ tag
] || wrapMap
._default
,
4343 div
= context
.createElement("div");
4345 // Go to html and back, then peel off extra wrappers
4346 div
.innerHTML
= wrap
[1] + elem
+ wrap
[2];
4348 // Move to the right depth
4350 div
= div
.lastChild
;
4353 // Remove IE's autoinserted <tbody> from table fragments
4354 if ( !jQuery
.support
.tbody
) {
4356 // String was a <table>, *may* have spurious <tbody>
4357 var hasBody
= rtbody
.test(elem
),
4358 tbody
= tag
=== "table" && !hasBody
?
4359 div
.firstChild
&& div
.firstChild
.childNodes
:
4361 // String was a bare <thead> or <tfoot>
4362 wrap
[1] === "<table>" && !hasBody
?
4366 for ( var j
= tbody
.length
- 1; j
>= 0 ; --j
) {
4367 if ( jQuery
.nodeName( tbody
[ j
], "tbody" ) && !tbody
[ j
].childNodes
.length
) {
4368 tbody
[ j
].parentNode
.removeChild( tbody
[ j
] );
4374 // IE completely kills leading whitespace when innerHTML is used
4375 if ( !jQuery
.support
.leadingWhitespace
&& rleadingWhitespace
.test( elem
) ) {
4376 div
.insertBefore( context
.createTextNode( rleadingWhitespace
.exec(elem
)[0] ), div
.firstChild
);
4379 elem
= jQuery
.makeArray( div
.childNodes
);
4382 if ( elem
.nodeType
) {
4385 ret
= jQuery
.merge( ret
, elem
);
4391 for ( var i
= 0; ret
[i
]; i
++ ) {
4392 if ( scripts
&& jQuery
.nodeName( ret
[i
], "script" ) && (!ret
[i
].type
|| ret
[i
].type
.toLowerCase() === "text/javascript") ) {
4393 scripts
.push( ret
[i
].parentNode
? ret
[i
].parentNode
.removeChild( ret
[i
] ) : ret
[i
] );
4395 if ( ret
[i
].nodeType
=== 1 ) {
4396 ret
.splice
.apply( ret
, [i
+ 1, 0].concat(jQuery
.makeArray(ret
[i
].getElementsByTagName("script"))) );
4398 fragment
.appendChild( ret
[i
] );
4406 cleanData: function( elems
) {
4407 for ( var i
= 0, elem
, id
; (elem
= elems
[i
]) != null; i
++ ) {
4408 jQuery
.event
.remove( elem
);
4409 jQuery
.removeData( elem
);
4413 // exclude the following css properties to add px
4414 var rexclude
= /z-?index|font-?weight|opacity|zoom|line-?height/i,
4415 ralpha
= /alpha\([^)]*\)/,
4416 ropacity
= /opacity=([^)]*)/,
4418 rdashAlpha
= /-([a-z])/ig,
4419 rupper
= /([A-Z])/g,
4420 rnumpx
= /^-?\d+(?:px)?$/i,
4423 cssShow
= { position
: "absolute", visibility
: "hidden", display
:"block" },
4424 cssWidth
= [ "Left", "Right" ],
4425 cssHeight
= [ "Top", "Bottom" ],
4427 // cache check for defaultView.getComputedStyle
4428 getComputedStyle
= document
.defaultView
&& document
.defaultView
.getComputedStyle
,
4429 // normalize float css property
4430 styleFloat
= jQuery
.support
.cssFloat
? "cssFloat" : "styleFloat",
4431 fcamelCase = function( all
, letter
) {
4432 return letter
.toUpperCase();
4435 jQuery
.fn
.css = function( name
, value
) {
4436 return access( this, name
, value
, true, function( elem
, name
, value
) {
4437 if ( value
=== undefined ) {
4438 return jQuery
.curCSS( elem
, name
);
4441 if ( typeof value
=== "number" && !rexclude
.test(name
) ) {
4445 jQuery
.style( elem
, name
, value
);
4450 style: function( elem
, name
, value
) {
4451 // don't set styles on text and comment nodes
4452 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
4456 // ignore negative width and height values #1599
4457 if ( (name
=== "width" || name
=== "height") && parseFloat(value
) < 0 ) {
4461 var style
= elem
.style
|| elem
, set = value
!== undefined;
4463 // IE uses filters for opacity
4464 if ( !jQuery
.support
.opacity
&& name
=== "opacity" ) {
4466 // IE has trouble with opacity if it does not have layout
4467 // Force it by setting the zoom level
4470 // Set the alpha filter to set the opacity
4471 var opacity
= parseInt( value
, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value
* 100 + ")";
4472 var filter
= style
.filter
|| jQuery
.curCSS( elem
, "filter" ) || "";
4473 style
.filter
= ralpha
.test(filter
) ? filter
.replace(ralpha
, opacity
) : opacity
;
4476 return style
.filter
&& style
.filter
.indexOf("opacity=") >= 0 ?
4477 (parseFloat( ropacity
.exec(style
.filter
)[1] ) / 100) + "":
4481 // Make sure we're using the right name for getting the float value
4482 if ( rfloat
.test( name
) ) {
4486 name
= name
.replace(rdashAlpha
, fcamelCase
);
4489 style
[ name
] = value
;
4492 return style
[ name
];
4495 css: function( elem
, name
, force
, extra
) {
4496 if ( name
=== "width" || name
=== "height" ) {
4497 var val
, props
= cssShow
, which
= name
=== "width" ? cssWidth
: cssHeight
;
4500 val
= name
=== "width" ? elem
.offsetWidth
: elem
.offsetHeight
;
4502 if ( extra
=== "border" ) {
4506 jQuery
.each( which
, function() {
4508 val
-= parseFloat(jQuery
.curCSS( elem
, "padding" + this, true)) || 0;
4511 if ( extra
=== "margin" ) {
4512 val
+= parseFloat(jQuery
.curCSS( elem
, "margin" + this, true)) || 0;
4514 val
-= parseFloat(jQuery
.curCSS( elem
, "border" + this + "Width", true)) || 0;
4519 if ( elem
.offsetWidth
!== 0 ) {
4522 jQuery
.swap( elem
, props
, getWH
);
4525 return Math
.max(0, Math
.round(val
));
4528 return jQuery
.curCSS( elem
, name
, force
);
4531 curCSS: function( elem
, name
, force
) {
4532 var ret
, style
= elem
.style
, filter
;
4534 // IE uses filters for opacity
4535 if ( !jQuery
.support
.opacity
&& name
=== "opacity" && elem
.currentStyle
) {
4536 ret
= ropacity
.test(elem
.currentStyle
.filter
|| "") ?
4537 (parseFloat(RegExp
.$1) / 100) + "" :
4545 // Make sure we're using the right name for getting the float value
4546 if ( rfloat
.test( name
) ) {
4550 if ( !force
&& style
&& style
[ name
] ) {
4551 ret
= style
[ name
];
4553 } else if ( getComputedStyle
) {
4555 // Only "float" is needed here
4556 if ( rfloat
.test( name
) ) {
4560 name
= name
.replace( rupper
, "-$1" ).toLowerCase();
4562 var defaultView
= elem
.ownerDocument
.defaultView
;
4564 if ( !defaultView
) {
4568 var computedStyle
= defaultView
.getComputedStyle( elem
, null );
4570 if ( computedStyle
) {
4571 ret
= computedStyle
.getPropertyValue( name
);
4574 // We should always get a number back from opacity
4575 if ( name
=== "opacity" && ret
=== "" ) {
4579 } else if ( elem
.currentStyle
) {
4580 var camelCase
= name
.replace(rdashAlpha
, fcamelCase
);
4582 ret
= elem
.currentStyle
[ name
] || elem
.currentStyle
[ camelCase
];
4584 // From the awesome hack by Dean Edwards
4585 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
4587 // If we're not dealing with a regular pixel number
4588 // but a number that has a weird ending, we need to convert it to pixels
4589 if ( !rnumpx
.test( ret
) && rnum
.test( ret
) ) {
4590 // Remember the original values
4591 var left
= style
.left
, rsLeft
= elem
.runtimeStyle
.left
;
4593 // Put in the new values to get a computed value out
4594 elem
.runtimeStyle
.left
= elem
.currentStyle
.left
;
4595 style
.left
= camelCase
=== "fontSize" ? "1em" : (ret
|| 0);
4596 ret
= style
.pixelLeft
+ "px";
4598 // Revert the changed values
4600 elem
.runtimeStyle
.left
= rsLeft
;
4607 // A method for quickly swapping in/out CSS properties to get correct calculations
4608 swap: function( elem
, options
, callback
) {
4611 // Remember the old values, and insert the new ones
4612 for ( var name
in options
) {
4613 old
[ name
] = elem
.style
[ name
];
4614 elem
.style
[ name
] = options
[ name
];
4617 callback
.call( elem
);
4619 // Revert the old values
4620 for ( var name
in options
) {
4621 elem
.style
[ name
] = old
[ name
];
4626 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
4627 jQuery
.expr
.filters
.hidden = function( elem
) {
4628 var width
= elem
.offsetWidth
, height
= elem
.offsetHeight
,
4629 skip
= elem
.nodeName
.toLowerCase() === "tr";
4631 return width
=== 0 && height
=== 0 && !skip
?
4633 width
> 0 && height
> 0 && !skip
?
4635 jQuery
.curCSS(elem
, "display") === "none";
4638 jQuery
.expr
.filters
.visible = function( elem
) {
4639 return !jQuery
.expr
.filters
.hidden( elem
);
4643 rscript
= /<script(.|\s)*?\/script>/gi,
4644 rselectTextarea
= /select|textarea/i,
4645 rinput
= /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
4648 rts
= /(\?|&)_=.*?(&|$)/,
4649 rurl
= /^(\w+:)?\/\/([^\/?#]+)/,
4653 // Keep a copy of the old load
4654 _load
: jQuery
.fn
.load
,
4656 load: function( url
, params
, callback
) {
4657 if ( typeof url
!== "string" ) {
4658 return this._load( url
);
4660 // Don't do a request if no elements are being requested
4661 } else if ( !this.length
) {
4665 var off
= url
.indexOf(" ");
4667 var selector
= url
.slice(off
, url
.length
);
4668 url
= url
.slice(0, off
);
4671 // Default to a GET request
4674 // If the second parameter was provided
4676 // If it's a function
4677 if ( jQuery
.isFunction( params
) ) {
4678 // We assume that it's the callback
4682 // Otherwise, build a param string
4683 } else if ( typeof params
=== "object" ) {
4684 params
= jQuery
.param( params
, jQuery
.ajaxSettings
.traditional
);
4691 // Request the remote document
4697 complete: function( res
, status
) {
4698 // If successful, inject the HTML into all the matched elements
4699 if ( status
=== "success" || status
=== "notmodified" ) {
4700 // See if a selector was specified
4701 self
.html( selector
?
4702 // Create a dummy div to hold the results
4704 // inject the contents of the document in, removing the scripts
4705 // to avoid any 'Permission Denied' errors in IE
4706 .append(res
.responseText
.replace(rscript
, ""))
4708 // Locate the specified elements
4711 // If not, just inject the full result
4716 self
.each( callback
, [res
.responseText
, status
, res
] );
4724 serialize: function() {
4725 return jQuery
.param(this.serializeArray());
4727 serializeArray: function() {
4728 return this.map(function() {
4729 return this.elements
? jQuery
.makeArray(this.elements
) : this;
4731 .filter(function() {
4732 return this.name
&& !this.disabled
&&
4733 (this.checked
|| rselectTextarea
.test(this.nodeName
) ||
4734 rinput
.test(this.type
));
4736 .map(function( i
, elem
) {
4737 var val
= jQuery(this).val();
4739 return val
== null ?
4741 jQuery
.isArray(val
) ?
4742 jQuery
.map( val
, function( val
, i
) {
4743 return { name
: elem
.name
, value
: val
};
4745 { name
: elem
.name
, value
: val
};
4750 // Attach a bunch of functions for handling common AJAX events
4751 jQuery
.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i
, o
) {
4752 jQuery
.fn
[o
] = function( f
) {
4753 return this.bind(o
, f
);
4759 get: function( url
, data
, callback
, type
) {
4760 // shift arguments if data argument was omited
4761 if ( jQuery
.isFunction( data
) ) {
4762 type
= type
|| callback
;
4767 return jQuery
.ajax({
4776 getScript: function( url
, callback
) {
4777 return jQuery
.get(url
, null, callback
, "script");
4780 getJSON: function( url
, data
, callback
) {
4781 return jQuery
.get(url
, data
, callback
, "json");
4784 post: function( url
, data
, callback
, type
) {
4785 // shift arguments if data argument was omited
4786 if ( jQuery
.isFunction( data
) ) {
4787 type
= type
|| callback
;
4792 return jQuery
.ajax({
4801 ajaxSetup: function( settings
) {
4802 jQuery
.extend( jQuery
.ajaxSettings
, settings
);
4809 contentType
: "application/x-www-form-urlencoded",
4819 // Create the request object; Microsoft failed to properly
4820 // implement the XMLHttpRequest in IE7 (can't request local files),
4821 // so we use the ActiveXObject when it is available
4822 // This function can be overriden by calling jQuery.ajaxSetup
4823 xhr
: window
.XMLHttpRequest
&& (window
.location
.protocol
!== "file:" || !window
.ActiveXObject
) ?
4825 return new window
.XMLHttpRequest();
4829 return new window
.ActiveXObject("Microsoft.XMLHTTP");
4833 xml
: "application/xml, text/xml",
4835 script
: "text/javascript, application/javascript",
4836 json
: "application/json, text/javascript",
4842 // Last-Modified header cache for next request
4846 ajax: function( origSettings
) {
4847 var s
= jQuery
.extend(true, {}, jQuery
.ajaxSettings
, origSettings
);
4849 var jsonp
, status
, data
,
4850 callbackContext
= origSettings
&& origSettings
.context
|| s
,
4851 type
= s
.type
.toUpperCase();
4853 // convert data if not already a string
4854 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
4855 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
4858 // Handle JSONP Parameter Callbacks
4859 if ( s
.dataType
=== "jsonp" ) {
4860 if ( type
=== "GET" ) {
4861 if ( !jsre
.test( s
.url
) ) {
4862 s
.url
+= (rquery
.test( s
.url
) ? "&" : "?") + (s
.jsonp
|| "callback") + "=?";
4864 } else if ( !s
.data
|| !jsre
.test(s
.data
) ) {
4865 s
.data
= (s
.data
? s
.data
+ "&" : "") + (s
.jsonp
|| "callback") + "=?";
4867 s
.dataType
= "json";
4870 // Build temporary JSONP function
4871 if ( s
.dataType
=== "json" && (s
.data
&& jsre
.test(s
.data
) || jsre
.test(s
.url
)) ) {
4872 jsonp
= s
.jsonpCallback
|| ("jsonp" + jsc
++);
4874 // Replace the =? sequence both in the query string and the data
4876 s
.data
= (s
.data
+ "").replace(jsre
, "=" + jsonp
+ "$1");
4879 s
.url
= s
.url
.replace(jsre
, "=" + jsonp
+ "$1");
4881 // We need to make sure
4882 // that a JSONP style response is executed properly
4883 s
.dataType
= "script";
4885 // Handle JSONP-style loading
4886 window
[ jsonp
] = window
[ jsonp
] || function( tmp
) {
4891 window
[ jsonp
] = undefined;
4894 delete window
[ jsonp
];
4898 head
.removeChild( script
);
4903 if ( s
.dataType
=== "script" && s
.cache
=== null ) {
4907 if ( s
.cache
=== false && type
=== "GET" ) {
4910 // try replacing _= if it is there
4911 var ret
= s
.url
.replace(rts
, "$1_=" + ts
+ "$2");
4913 // if nothing was replaced, add timestamp to the end
4914 s
.url
= ret
+ ((ret
=== s
.url
) ? (rquery
.test(s
.url
) ? "&" : "?") + "_=" + ts
: "");
4917 // If data is available, append data to url for get requests
4918 if ( s
.data
&& type
=== "GET" ) {
4919 s
.url
+= (rquery
.test(s
.url
) ? "&" : "?") + s
.data
;
4922 // Watch for a new set of requests
4923 if ( s
.global
&& ! jQuery
.active
++ ) {
4924 jQuery
.event
.trigger( "ajaxStart" );
4927 // Matches an absolute URL, and saves the domain
4928 var parts
= rurl
.exec( s
.url
),
4929 remote
= parts
&& (parts
[1] && parts
[1] !== location
.protocol
|| parts
[2] !== location
.host
);
4931 // If we're requesting a remote document
4932 // and trying to load JSON or Script with a GET
4933 if ( s
.dataType
=== "script" && type
=== "GET" && remote
) {
4934 var head
= document
.getElementsByTagName("head")[0] || document
.documentElement
;
4935 var script
= document
.createElement("script");
4937 if ( s
.scriptCharset
) {
4938 script
.charset
= s
.scriptCharset
;
4941 // Handle Script loading
4945 // Attach handlers for all browsers
4946 script
.onload
= script
.onreadystatechange = function() {
4947 if ( !done
&& (!this.readyState
||
4948 this.readyState
=== "loaded" || this.readyState
=== "complete") ) {
4953 // Handle memory leak in IE
4954 script
.onload
= script
.onreadystatechange
= null;
4955 if ( head
&& script
.parentNode
) {
4956 head
.removeChild( script
);
4962 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
4963 // This arises when a base node is used (#2709 and #4378).
4964 head
.insertBefore( script
, head
.firstChild
);
4966 // We handle everything using the script element injection
4970 var requestDone
= false;
4972 // Create the request object
4980 // Passing null username, generates a login popup on Opera (#2865)
4982 xhr
.open(type
, s
.url
, s
.async
, s
.username
, s
.password
);
4984 xhr
.open(type
, s
.url
, s
.async
);
4987 // Need an extra try/catch for cross domain requests in Firefox 3
4989 // Set the correct header, if data is being sent
4990 if ( s
.data
|| origSettings
&& origSettings
.contentType
) {
4991 xhr
.setRequestHeader("Content-Type", s
.contentType
);
4994 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
4995 if ( s
.ifModified
) {
4996 if ( jQuery
.lastModified
[s
.url
] ) {
4997 xhr
.setRequestHeader("If-Modified-Since", jQuery
.lastModified
[s
.url
]);
5000 if ( jQuery
.etag
[s
.url
] ) {
5001 xhr
.setRequestHeader("If-None-Match", jQuery
.etag
[s
.url
]);
5005 // Set header so the called script knows that it's an XMLHttpRequest
5006 // Only send the header if it's not a remote XHR
5008 xhr
.setRequestHeader("X-Requested-With", "XMLHttpRequest");
5011 // Set the Accepts header for the server, depending on the dataType
5012 xhr
.setRequestHeader("Accept", s
.dataType
&& s
.accepts
[ s
.dataType
] ?
5013 s
.accepts
[ s
.dataType
] + ", */*" :
5014 s
.accepts
._default
);
5017 // Allow custom headers/mimetypes and early abort
5018 if ( s
.beforeSend
&& s
.beforeSend
.call(callbackContext
, xhr
, s
) === false ) {
5019 // Handle the global AJAX counter
5020 if ( s
.global
&& ! --jQuery
.active
) {
5021 jQuery
.event
.trigger( "ajaxStop" );
5024 // close opended socket
5030 trigger("ajaxSend", [xhr
, s
]);
5033 // Wait for a response to come back
5034 var onreadystatechange
= xhr
.onreadystatechange = function( isTimeout
) {
5035 // The request was aborted
5036 if ( !xhr
|| xhr
.readyState
=== 0 || isTimeout
=== "abort" ) {
5037 // Opera doesn't call onreadystatechange before this point
5038 // so we simulate the call
5039 if ( !requestDone
) {
5045 xhr
.onreadystatechange
= jQuery
.noop
;
5048 // The transfer is complete and the data is available, or the request timed out
5049 } else if ( !requestDone
&& xhr
&& (xhr
.readyState
=== 4 || isTimeout
=== "timeout") ) {
5051 xhr
.onreadystatechange
= jQuery
.noop
;
5053 status
= isTimeout
=== "timeout" ?
5055 !jQuery
.httpSuccess( xhr
) ?
5057 s
.ifModified
&& jQuery
.httpNotModified( xhr
, s
.url
) ?
5063 if ( status
=== "success" ) {
5064 // Watch for, and catch, XML document parse errors
5066 // process the data (runs the xml through httpData regardless of callback)
5067 data
= jQuery
.httpData( xhr
, s
.dataType
, s
);
5069 status
= "parsererror";
5074 // Make sure that the request was successful or notmodified
5075 if ( status
=== "success" || status
=== "notmodified" ) {
5076 // JSONP handles its own success callback
5081 jQuery
.handleError(s
, xhr
, status
, errMsg
);
5084 // Fire the complete handlers
5087 if ( isTimeout
=== "timeout" ) {
5091 // Stop memory leaks
5098 // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
5099 // Opera doesn't fire onreadystatechange at all on abort
5101 var oldAbort
= xhr
.abort
;
5102 xhr
.abort = function() {
5104 oldAbort
.call( xhr
);
5107 onreadystatechange( "abort" );
5112 if ( s
.async
&& s
.timeout
> 0 ) {
5113 setTimeout(function() {
5114 // Check to see if the request is still happening
5115 if ( xhr
&& !requestDone
) {
5116 onreadystatechange( "timeout" );
5123 xhr
.send( type
=== "POST" || type
=== "PUT" || type
=== "DELETE" ? s
.data
: null );
5125 jQuery
.handleError(s
, xhr
, null, e
);
5126 // Fire the complete handlers
5130 // firefox 1.5 doesn't fire statechange for sync requests
5132 onreadystatechange();
5135 function success() {
5136 // If a local callback was specified, fire it and pass it the data
5138 s
.success
.call( callbackContext
, data
, status
, xhr
);
5141 // Fire the global callback
5143 trigger( "ajaxSuccess", [xhr
, s
] );
5147 function complete() {
5150 s
.complete
.call( callbackContext
, xhr
, status
);
5153 // The request was completed
5155 trigger( "ajaxComplete", [xhr
, s
] );
5158 // Handle the global AJAX counter
5159 if ( s
.global
&& ! --jQuery
.active
) {
5160 jQuery
.event
.trigger( "ajaxStop" );
5164 function trigger(type
, args
) {
5165 (s
.context
? jQuery(s
.context
) : jQuery
.event
).trigger(type
, args
);
5168 // return XMLHttpRequest to allow aborting the request etc.
5172 handleError: function( s
, xhr
, status
, e
) {
5173 // If a local callback was specified, fire it
5175 s
.error
.call( s
.context
|| s
, xhr
, status
, e
);
5178 // Fire the global callback
5180 (s
.context
? jQuery(s
.context
) : jQuery
.event
).trigger( "ajaxError", [xhr
, s
, e
] );
5184 // Counter for holding the number of active queries
5187 // Determines if an XMLHttpRequest was successful or not
5188 httpSuccess: function( xhr
) {
5190 // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
5191 return !xhr
.status
&& location
.protocol
=== "file:" ||
5192 // Opera returns 0 when status is 304
5193 ( xhr
.status
>= 200 && xhr
.status
< 300 ) ||
5194 xhr
.status
=== 304 || xhr
.status
=== 1223 || xhr
.status
=== 0;
5200 // Determines if an XMLHttpRequest returns NotModified
5201 httpNotModified: function( xhr
, url
) {
5202 var lastModified
= xhr
.getResponseHeader("Last-Modified"),
5203 etag
= xhr
.getResponseHeader("Etag");
5205 if ( lastModified
) {
5206 jQuery
.lastModified
[url
] = lastModified
;
5210 jQuery
.etag
[url
] = etag
;
5213 // Opera returns 0 when status is 304
5214 return xhr
.status
=== 304 || xhr
.status
=== 0;
5217 httpData: function( xhr
, type
, s
) {
5218 var ct
= xhr
.getResponseHeader("content-type") || "",
5219 xml
= type
=== "xml" || !type
&& ct
.indexOf("xml") >= 0,
5220 data
= xml
? xhr
.responseXML
: xhr
.responseText
;
5222 if ( xml
&& data
.documentElement
.nodeName
=== "parsererror" ) {
5223 jQuery
.error( "parsererror" );
5226 // Allow a pre-filtering function to sanitize the response
5227 // s is checked to keep backwards compatibility
5228 if ( s
&& s
.dataFilter
) {
5229 data
= s
.dataFilter( data
, type
);
5232 // The filter can actually parse the response
5233 if ( typeof data
=== "string" ) {
5234 // Get the JavaScript object, if JSON is used.
5235 if ( type
=== "json" || !type
&& ct
.indexOf("json") >= 0 ) {
5236 data
= jQuery
.parseJSON( data
);
5238 // If the type is "script", eval it in global context
5239 } else if ( type
=== "script" || !type
&& ct
.indexOf("javascript") >= 0 ) {
5240 jQuery
.globalEval( data
);
5247 // Serialize an array of form elements or a set of
5248 // key/values into a query string
5249 param: function( a
, traditional
) {
5252 // Set traditional to true for jQuery <= 1.3.2 behavior.
5253 if ( traditional
=== undefined ) {
5254 traditional
= jQuery
.ajaxSettings
.traditional
;
5257 // If an array was passed in, assume that it is an array of form elements.
5258 if ( jQuery
.isArray(a
) || a
.jquery
) {
5259 // Serialize the form elements
5260 jQuery
.each( a
, function() {
5261 add( this.name
, this.value
);
5265 // If traditional, encode the "old" way (the way 1.3.2 or older
5266 // did it), otherwise encode params recursively.
5267 for ( var prefix
in a
) {
5268 buildParams( prefix
, a
[prefix
] );
5272 // Return the resulting serialization
5273 return s
.join("&").replace(r20
, "+");
5275 function buildParams( prefix
, obj
) {
5276 if ( jQuery
.isArray(obj
) ) {
5277 // Serialize array item.
5278 jQuery
.each( obj
, function( i
, v
) {
5279 if ( traditional
) {
5280 // Treat each array item as a scalar.
5283 // If array item is non-scalar (array or object), encode its
5284 // numeric index to resolve deserialization ambiguity issues.
5285 // Note that rack (as of 1.0.0) can't currently deserialize
5286 // nested arrays properly, and attempting to do so may cause
5287 // a server error. Possible fixes are to modify rack's
5288 // deserialization algorithm or to provide an option or flag
5289 // to force array serialization to be shallow.
5290 buildParams( prefix
+ "[" + ( typeof v
=== "object" || jQuery
.isArray(v
) ? i
: "" ) + "]", v
);
5294 } else if ( !traditional
&& obj
!= null && typeof obj
=== "object" ) {
5295 // Serialize object item.
5296 jQuery
.each( obj
, function( k
, v
) {
5297 buildParams( prefix
+ "[" + k
+ "]", v
);
5301 // Serialize scalar item.
5306 function add( key
, value
) {
5307 // If value is a function, invoke it and return its value
5308 value
= jQuery
.isFunction(value
) ? value() : value
;
5309 s
[ s
.length
] = encodeURIComponent(key
) + "=" + encodeURIComponent(value
);
5313 var elemdisplay
= {},
5314 rfxtypes
= /toggle|show|hide/,
5315 rfxnum
= /^([+-]=)?([\d+-.]+)(.*)$/,
5318 // height animations
5319 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
5321 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
5322 // opacity animations
5327 show: function( speed
, callback
) {
5328 if ( speed
|| speed
=== 0) {
5329 return this.animate( genFx("show", 3), speed
, callback
);
5332 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
5333 var old
= jQuery
.data(this[i
], "olddisplay");
5335 this[i
].style
.display
= old
|| "";
5337 if ( jQuery
.css(this[i
], "display") === "none" ) {
5338 var nodeName
= this[i
].nodeName
, display
;
5340 if ( elemdisplay
[ nodeName
] ) {
5341 display
= elemdisplay
[ nodeName
];
5344 var elem
= jQuery("<" + nodeName
+ " />").appendTo("body");
5346 display
= elem
.css("display");
5348 if ( display
=== "none" ) {
5354 elemdisplay
[ nodeName
] = display
;
5357 jQuery
.data(this[i
], "olddisplay", display
);
5361 // Set the display of the elements in a second loop
5362 // to avoid the constant reflow
5363 for ( var j
= 0, k
= this.length
; j
< k
; j
++ ) {
5364 this[j
].style
.display
= jQuery
.data(this[j
], "olddisplay") || "";
5371 hide: function( speed
, callback
) {
5372 if ( speed
|| speed
=== 0 ) {
5373 return this.animate( genFx("hide", 3), speed
, callback
);
5376 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
5377 var old
= jQuery
.data(this[i
], "olddisplay");
5378 if ( !old
&& old
!== "none" ) {
5379 jQuery
.data(this[i
], "olddisplay", jQuery
.css(this[i
], "display"));
5383 // Set the display of the elements in a second loop
5384 // to avoid the constant reflow
5385 for ( var j
= 0, k
= this.length
; j
< k
; j
++ ) {
5386 this[j
].style
.display
= "none";
5393 // Save the old toggle function
5394 _toggle
: jQuery
.fn
.toggle
,
5396 toggle: function( fn
, fn2
) {
5397 var bool
= typeof fn
=== "boolean";
5399 if ( jQuery
.isFunction(fn
) && jQuery
.isFunction(fn2
) ) {
5400 this._toggle
.apply( this, arguments
);
5402 } else if ( fn
== null || bool
) {
5403 this.each(function() {
5404 var state
= bool
? fn
: jQuery(this).is(":hidden");
5405 jQuery(this)[ state
? "show" : "hide" ]();
5409 this.animate(genFx("toggle", 3), fn
, fn2
);
5415 fadeTo: function( speed
, to
, callback
) {
5416 return this.filter(":hidden").css("opacity", 0).show().end()
5417 .animate({opacity
: to
}, speed
, callback
);
5420 animate: function( prop
, speed
, easing
, callback
) {
5421 var optall
= jQuery
.speed(speed
, easing
, callback
);
5423 if ( jQuery
.isEmptyObject( prop
) ) {
5424 return this.each( optall
.complete
);
5427 return this[ optall
.queue
=== false ? "each" : "queue" ](function() {
5428 var opt
= jQuery
.extend({}, optall
), p
,
5429 hidden
= this.nodeType
=== 1 && jQuery(this).is(":hidden"),
5433 var name
= p
.replace(rdashAlpha
, fcamelCase
);
5436 prop
[ name
] = prop
[ p
];
5441 if ( prop
[p
] === "hide" && hidden
|| prop
[p
] === "show" && !hidden
) {
5442 return opt
.complete
.call(this);
5445 if ( ( p
=== "height" || p
=== "width" ) && this.style
) {
5446 // Store display property
5447 opt
.display
= jQuery
.css(this, "display");
5449 // Make sure that nothing sneaks out
5450 opt
.overflow
= this.style
.overflow
;
5453 if ( jQuery
.isArray( prop
[p
] ) ) {
5454 // Create (if needed) and add to specialEasing
5455 (opt
.specialEasing
= opt
.specialEasing
|| {})[p
] = prop
[p
][1];
5456 prop
[p
] = prop
[p
][0];
5460 if ( opt
.overflow
!= null ) {
5461 this.style
.overflow
= "hidden";
5464 opt
.curAnim
= jQuery
.extend({}, prop
);
5466 jQuery
.each( prop
, function( name
, val
) {
5467 var e
= new jQuery
.fx( self
, opt
, name
);
5469 if ( rfxtypes
.test(val
) ) {
5470 e
[ val
=== "toggle" ? hidden
? "show" : "hide" : val
]( prop
);
5473 var parts
= rfxnum
.exec(val
),
5474 start
= e
.cur(true) || 0;
5477 var end
= parseFloat( parts
[2] ),
5478 unit
= parts
[3] || "px";
5480 // We need to compute starting value
5481 if ( unit
!== "px" ) {
5482 self
.style
[ name
] = (end
|| 1) + unit
;
5483 start
= ((end
|| 1) / e
.cur(true)) * start
;
5484 self
.style
[ name
] = start
+ unit
;
5487 // If a +=/-= token was provided, we're doing a relative animation
5489 end
= ((parts
[1] === "-=" ? -1 : 1) * end
) + start
;
5492 e
.custom( start
, end
, unit
);
5495 e
.custom( start
, val
, "" );
5500 // For JS strict compliance
5505 stop: function( clearQueue
, gotoEnd
) {
5506 var timers
= jQuery
.timers
;
5512 this.each(function() {
5513 // go in reverse order so anything added to the queue during the loop is ignored
5514 for ( var i
= timers
.length
- 1; i
>= 0; i
-- ) {
5515 if ( timers
[i
].elem
=== this ) {
5517 // force the next step to be the last
5521 timers
.splice(i
, 1);
5526 // start the next in the queue if the last step wasn't forced
5536 // Generate shortcuts for custom animations
5538 slideDown
: genFx("show", 1),
5539 slideUp
: genFx("hide", 1),
5540 slideToggle
: genFx("toggle", 1),
5541 fadeIn
: { opacity
: "show" },
5542 fadeOut
: { opacity
: "hide" }
5543 }, function( name
, props
) {
5544 jQuery
.fn
[ name
] = function( speed
, callback
) {
5545 return this.animate( props
, speed
, callback
);
5550 speed: function( speed
, easing
, fn
) {
5551 var opt
= speed
&& typeof speed
=== "object" ? speed
: {
5552 complete
: fn
|| !fn
&& easing
||
5553 jQuery
.isFunction( speed
) && speed
,
5555 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction(easing
) && easing
5558 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
5559 jQuery
.fx
.speeds
[opt
.duration
] || jQuery
.fx
.speeds
._default
;
5562 opt
.old
= opt
.complete
;
5563 opt
.complete = function() {
5564 if ( opt
.queue
!== false ) {
5565 jQuery(this).dequeue();
5567 if ( jQuery
.isFunction( opt
.old
) ) {
5568 opt
.old
.call( this );
5576 linear: function( p
, n
, firstNum
, diff
) {
5577 return firstNum
+ diff
* p
;
5579 swing: function( p
, n
, firstNum
, diff
) {
5580 return ((-Math
.cos(p
*Math
.PI
)/2) + 0.5) * diff
+ firstNum
;
5586 fx: function( elem
, options
, prop
) {
5587 this.options
= options
;
5591 if ( !options
.orig
) {
5598 jQuery
.fx
.prototype = {
5599 // Simple function for setting a style value
5600 update: function() {
5601 if ( this.options
.step
) {
5602 this.options
.step
.call( this.elem
, this.now
, this );
5605 (jQuery
.fx
.step
[this.prop
] || jQuery
.fx
.step
._default
)( this );
5607 // Set display property to block for height/width animations
5608 if ( ( this.prop
=== "height" || this.prop
=== "width" ) && this.elem
.style
) {
5609 this.elem
.style
.display
= "block";
5613 // Get the current size
5614 cur: function( force
) {
5615 if ( this.elem
[this.prop
] != null && (!this.elem
.style
|| this.elem
.style
[this.prop
] == null) ) {
5616 return this.elem
[ this.prop
];
5619 var r
= parseFloat(jQuery
.css(this.elem
, this.prop
, force
));
5620 return r
&& r
> -10000 ? r
: parseFloat(jQuery
.curCSS(this.elem
, this.prop
)) || 0;
5623 // Start an animation from one number to another
5624 custom: function( from, to
, unit
) {
5625 this.startTime
= now();
5628 this.unit
= unit
|| this.unit
|| "px";
5629 this.now
= this.start
;
5630 this.pos
= this.state
= 0;
5633 function t( gotoEnd
) {
5634 return self
.step(gotoEnd
);
5639 if ( t() && jQuery
.timers
.push(t
) && !timerId
) {
5640 timerId
= setInterval(jQuery
.fx
.tick
, 13);
5644 // Simple 'show' function
5646 // Remember where we started, so that we can go back to it later
5647 this.options
.orig
[this.prop
] = jQuery
.style( this.elem
, this.prop
);
5648 this.options
.show
= true;
5650 // Begin the animation
5651 // Make sure that we start at a small width/height to avoid any
5653 this.custom(this.prop
=== "width" || this.prop
=== "height" ? 1 : 0, this.cur());
5655 // Start by showing the element
5656 jQuery( this.elem
).show();
5659 // Simple 'hide' function
5661 // Remember where we started, so that we can go back to it later
5662 this.options
.orig
[this.prop
] = jQuery
.style( this.elem
, this.prop
);
5663 this.options
.hide
= true;
5665 // Begin the animation
5666 this.custom(this.cur(), 0);
5669 // Each step of an animation
5670 step: function( gotoEnd
) {
5671 var t
= now(), done
= true;
5673 if ( gotoEnd
|| t
>= this.options
.duration
+ this.startTime
) {
5674 this.now
= this.end
;
5675 this.pos
= this.state
= 1;
5678 this.options
.curAnim
[ this.prop
] = true;
5680 for ( var i
in this.options
.curAnim
) {
5681 if ( this.options
.curAnim
[i
] !== true ) {
5687 if ( this.options
.display
!= null ) {
5688 // Reset the overflow
5689 this.elem
.style
.overflow
= this.options
.overflow
;
5691 // Reset the display
5692 var old
= jQuery
.data(this.elem
, "olddisplay");
5693 this.elem
.style
.display
= old
? old
: this.options
.display
;
5695 if ( jQuery
.css(this.elem
, "display") === "none" ) {
5696 this.elem
.style
.display
= "block";
5700 // Hide the element if the "hide" operation was done
5701 if ( this.options
.hide
) {
5702 jQuery(this.elem
).hide();
5705 // Reset the properties, if the item has been hidden or shown
5706 if ( this.options
.hide
|| this.options
.show
) {
5707 for ( var p
in this.options
.curAnim
) {
5708 jQuery
.style(this.elem
, p
, this.options
.orig
[p
]);
5712 // Execute the complete function
5713 this.options
.complete
.call( this.elem
);
5719 var n
= t
- this.startTime
;
5720 this.state
= n
/ this.options
.duration
;
5722 // Perform the easing function, defaults to swing
5723 var specialEasing
= this.options
.specialEasing
&& this.options
.specialEasing
[this.prop
];
5724 var defaultEasing
= this.options
.easing
|| (jQuery
.easing
.swing
? "swing" : "linear");
5725 this.pos
= jQuery
.easing
[specialEasing
|| defaultEasing
](this.state
, n
, 0, 1, this.options
.duration
);
5726 this.now
= this.start
+ ((this.end
- this.start
) * this.pos
);
5728 // Perform the next step of the animation
5736 jQuery
.extend( jQuery
.fx
, {
5738 var timers
= jQuery
.timers
;
5740 for ( var i
= 0; i
< timers
.length
; i
++ ) {
5741 if ( !timers
[i
]() ) {
5742 timers
.splice(i
--, 1);
5746 if ( !timers
.length
) {
5752 clearInterval( timerId
);
5764 opacity: function( fx
) {
5765 jQuery
.style(fx
.elem
, "opacity", fx
.now
);
5768 _default: function( fx
) {
5769 if ( fx
.elem
.style
&& fx
.elem
.style
[ fx
.prop
] != null ) {
5770 fx
.elem
.style
[ fx
.prop
] = (fx
.prop
=== "width" || fx
.prop
=== "height" ? Math
.max(0, fx
.now
) : fx
.now
) + fx
.unit
;
5772 fx
.elem
[ fx
.prop
] = fx
.now
;
5778 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
5779 jQuery
.expr
.filters
.animated = function( elem
) {
5780 return jQuery
.grep(jQuery
.timers
, function( fn
) {
5781 return elem
=== fn
.elem
;
5786 function genFx( type
, num
) {
5789 jQuery
.each( fxAttrs
.concat
.apply([], fxAttrs
.slice(0,num
)), function() {
5795 if ( "getBoundingClientRect" in document
.documentElement
) {
5796 jQuery
.fn
.offset = function( options
) {
5800 return this.each(function( i
) {
5801 jQuery
.offset
.setOffset( this, options
, i
);
5805 if ( !elem
|| !elem
.ownerDocument
) {
5809 if ( elem
=== elem
.ownerDocument
.body
) {
5810 return jQuery
.offset
.bodyOffset( elem
);
5813 var box
= elem
.getBoundingClientRect(), doc
= elem
.ownerDocument
, body
= doc
.body
, docElem
= doc
.documentElement
,
5814 clientTop
= docElem
.clientTop
|| body
.clientTop
|| 0, clientLeft
= docElem
.clientLeft
|| body
.clientLeft
|| 0,
5815 top
= box
.top
+ (self
.pageYOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollTop
|| body
.scrollTop
) - clientTop
,
5816 left
= box
.left
+ (self
.pageXOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollLeft
|| body
.scrollLeft
) - clientLeft
;
5818 return { top
: top
, left
: left
};
5822 jQuery
.fn
.offset = function( options
) {
5826 return this.each(function( i
) {
5827 jQuery
.offset
.setOffset( this, options
, i
);
5831 if ( !elem
|| !elem
.ownerDocument
) {
5835 if ( elem
=== elem
.ownerDocument
.body
) {
5836 return jQuery
.offset
.bodyOffset( elem
);
5839 jQuery
.offset
.initialize();
5841 var offsetParent
= elem
.offsetParent
, prevOffsetParent
= elem
,
5842 doc
= elem
.ownerDocument
, computedStyle
, docElem
= doc
.documentElement
,
5843 body
= doc
.body
, defaultView
= doc
.defaultView
,
5844 prevComputedStyle
= defaultView
? defaultView
.getComputedStyle( elem
, null ) : elem
.currentStyle
,
5845 top
= elem
.offsetTop
, left
= elem
.offsetLeft
;
5847 while ( (elem
= elem
.parentNode
) && elem
!== body
&& elem
!== docElem
) {
5848 if ( jQuery
.offset
.supportsFixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
5852 computedStyle
= defaultView
? defaultView
.getComputedStyle(elem
, null) : elem
.currentStyle
;
5853 top
-= elem
.scrollTop
;
5854 left
-= elem
.scrollLeft
;
5856 if ( elem
=== offsetParent
) {
5857 top
+= elem
.offsetTop
;
5858 left
+= elem
.offsetLeft
;
5860 if ( jQuery
.offset
.doesNotAddBorder
&& !(jQuery
.offset
.doesAddBorderForTableAndCells
&& /^t(able|d|h)$/i.test(elem
.nodeName
)) ) {
5861 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
5862 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
5865 prevOffsetParent
= offsetParent
, offsetParent
= elem
.offsetParent
;
5868 if ( jQuery
.offset
.subtractsBorderForOverflowNotVisible
&& computedStyle
.overflow
!== "visible" ) {
5869 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
5870 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
5873 prevComputedStyle
= computedStyle
;
5876 if ( prevComputedStyle
.position
=== "relative" || prevComputedStyle
.position
=== "static" ) {
5877 top
+= body
.offsetTop
;
5878 left
+= body
.offsetLeft
;
5881 if ( jQuery
.offset
.supportsFixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
5882 top
+= Math
.max( docElem
.scrollTop
, body
.scrollTop
);
5883 left
+= Math
.max( docElem
.scrollLeft
, body
.scrollLeft
);
5886 return { top
: top
, left
: left
};
5891 initialize: function() {
5892 var body
= document
.body
, container
= document
.createElement("div"), innerDiv
, checkDiv
, table
, td
, bodyMarginTop
= parseFloat( jQuery
.curCSS(body
, "marginTop", true) ) || 0,
5893 html
= "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
5895 jQuery
.extend( container
.style
, { position
: "absolute", top
: 0, left
: 0, margin
: 0, border
: 0, width
: "1px", height
: "1px", visibility
: "hidden" } );
5897 container
.innerHTML
= html
;
5898 body
.insertBefore( container
, body
.firstChild
);
5899 innerDiv
= container
.firstChild
;
5900 checkDiv
= innerDiv
.firstChild
;
5901 td
= innerDiv
.nextSibling
.firstChild
.firstChild
;
5903 this.doesNotAddBorder
= (checkDiv
.offsetTop
!== 5);
5904 this.doesAddBorderForTableAndCells
= (td
.offsetTop
=== 5);
5906 checkDiv
.style
.position
= "fixed", checkDiv
.style
.top
= "20px";
5907 // safari subtracts parent border width here which is 5px
5908 this.supportsFixedPosition
= (checkDiv
.offsetTop
=== 20 || checkDiv
.offsetTop
=== 15);
5909 checkDiv
.style
.position
= checkDiv
.style
.top
= "";
5911 innerDiv
.style
.overflow
= "hidden", innerDiv
.style
.position
= "relative";
5912 this.subtractsBorderForOverflowNotVisible
= (checkDiv
.offsetTop
=== -5);
5914 this.doesNotIncludeMarginInBodyOffset
= (body
.offsetTop
!== bodyMarginTop
);
5916 body
.removeChild( container
);
5917 body
= container
= innerDiv
= checkDiv
= table
= td
= null;
5918 jQuery
.offset
.initialize
= jQuery
.noop
;
5921 bodyOffset: function( body
) {
5922 var top
= body
.offsetTop
, left
= body
.offsetLeft
;
5924 jQuery
.offset
.initialize();
5926 if ( jQuery
.offset
.doesNotIncludeMarginInBodyOffset
) {
5927 top
+= parseFloat( jQuery
.curCSS(body
, "marginTop", true) ) || 0;
5928 left
+= parseFloat( jQuery
.curCSS(body
, "marginLeft", true) ) || 0;
5931 return { top
: top
, left
: left
};
5934 setOffset: function( elem
, options
, i
) {
5935 // set position first, in-case top/left are set even on static elem
5936 if ( /static/.test( jQuery
.curCSS( elem
, "position" ) ) ) {
5937 elem
.style
.position
= "relative";
5939 var curElem
= jQuery( elem
),
5940 curOffset
= curElem
.offset(),
5941 curTop
= parseInt( jQuery
.curCSS( elem
, "top", true ), 10 ) || 0,
5942 curLeft
= parseInt( jQuery
.curCSS( elem
, "left", true ), 10 ) || 0;
5944 if ( jQuery
.isFunction( options
) ) {
5945 options
= options
.call( elem
, i
, curOffset
);
5949 top
: (options
.top
- curOffset
.top
) + curTop
,
5950 left
: (options
.left
- curOffset
.left
) + curLeft
5953 if ( "using" in options
) {
5954 options
.using
.call( elem
, props
);
5956 curElem
.css( props
);
5963 position: function() {
5970 // Get *real* offsetParent
5971 offsetParent
= this.offsetParent(),
5973 // Get correct offsets
5974 offset
= this.offset(),
5975 parentOffset
= /^body|html$/i.test(offsetParent
[0].nodeName
) ? { top
: 0, left
: 0 } : offsetParent
.offset();
5977 // Subtract element margins
5978 // note: when an element has margin: auto the offsetLeft and marginLeft
5979 // are the same in Safari causing offset.left to incorrectly be 0
5980 offset
.top
-= parseFloat( jQuery
.curCSS(elem
, "marginTop", true) ) || 0;
5981 offset
.left
-= parseFloat( jQuery
.curCSS(elem
, "marginLeft", true) ) || 0;
5983 // Add offsetParent borders
5984 parentOffset
.top
+= parseFloat( jQuery
.curCSS(offsetParent
[0], "borderTopWidth", true) ) || 0;
5985 parentOffset
.left
+= parseFloat( jQuery
.curCSS(offsetParent
[0], "borderLeftWidth", true) ) || 0;
5987 // Subtract the two offsets
5989 top
: offset
.top
- parentOffset
.top
,
5990 left
: offset
.left
- parentOffset
.left
5994 offsetParent: function() {
5995 return this.map(function() {
5996 var offsetParent
= this.offsetParent
|| document
.body
;
5997 while ( offsetParent
&& (!/^body|html$/i.test(offsetParent
.nodeName
) && jQuery
.css(offsetParent
, "position") === "static") ) {
5998 offsetParent
= offsetParent
.offsetParent
;
6000 return offsetParent
;
6006 // Create scrollLeft and scrollTop methods
6007 jQuery
.each( ["Left", "Top"], function( i
, name
) {
6008 var method
= "scroll" + name
;
6010 jQuery
.fn
[ method
] = function(val
) {
6011 var elem
= this[0], win
;
6017 if ( val
!== undefined ) {
6018 // Set the scroll offset
6019 return this.each(function() {
6020 win
= getWindow( this );
6024 !i
? val
: jQuery(win
).scrollLeft(),
6025 i
? val
: jQuery(win
).scrollTop()
6029 this[ method
] = val
;
6033 win
= getWindow( elem
);
6035 // Return the scroll offset
6036 return win
? ("pageXOffset" in win
) ? win
[ i
? "pageYOffset" : "pageXOffset" ] :
6037 jQuery
.support
.boxModel
&& win
.document
.documentElement
[ method
] ||
6038 win
.document
.body
[ method
] :
6044 function getWindow( elem
) {
6045 return ("scrollTo" in elem
&& elem
.document
) ?
6047 elem
.nodeType
=== 9 ?
6048 elem
.defaultView
|| elem
.parentWindow
:
6051 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
6052 jQuery
.each([ "Height", "Width" ], function( i
, name
) {
6054 var type
= name
.toLowerCase();
6056 // innerHeight and innerWidth
6057 jQuery
.fn
["inner" + name
] = function() {
6059 jQuery
.css( this[0], type
, false, "padding" ) :
6063 // outerHeight and outerWidth
6064 jQuery
.fn
["outer" + name
] = function( margin
) {
6066 jQuery
.css( this[0], type
, false, margin
? "margin" : "border" ) :
6070 jQuery
.fn
[ type
] = function( size
) {
6071 // Get window width or height
6074 return size
== null ? null : this;
6077 if ( jQuery
.isFunction( size
) ) {
6078 return this.each(function( i
) {
6079 var self
= jQuery( this );
6080 self
[ type
]( size
.call( this, i
, self
[ type
]() ) );
6084 return ("scrollTo" in elem
&& elem
.document
) ? // does it walk and quack like a window?
6085 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
6086 elem
.document
.compatMode
=== "CSS1Compat" && elem
.document
.documentElement
[ "client" + name
] ||
6087 elem
.document
.body
[ "client" + name
] :
6089 // Get document width or height
6090 (elem
.nodeType
=== 9) ? // is it a document
6091 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
6093 elem
.documentElement
["client" + name
],
6094 elem
.body
["scroll" + name
], elem
.documentElement
["scroll" + name
],
6095 elem
.body
["offset" + name
], elem
.documentElement
["offset" + name
]
6098 // Get or set width or height on the element
6099 size
=== undefined ?
6100 // Get width or height on the element
6101 jQuery
.css( elem
, type
) :
6103 // Set the width or height on the element (default to pixels if value is unitless)
6104 this.css( type
, typeof size
=== "string" ? size
: size
+ "px" );
6108 // Expose jQuery to the global object
6109 window
.jQuery
= window
.$ = jQuery
;